question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[FEATURE REQUEST] Getting interpolation type by String

See original GitHub issue

Issue details

Requesting for feature addition to get interpolation instance by interpolation name.

Sometimes I’d like to be able to get an interpolation type from, for example, a text file. The Interpolation class doesn’t feature a method to get an instance of Interpolation via String input. Current workaround would be something like

private Interpolation getInterpolationByName(String name) {
    try {

        Field field = Interpolation.class.getField(name);
        return (Interpolation) field.get(Interpolation.class);

    } catch (NoSuchFieldException | IllegalAccessException ex) {
        ex.printStackTrace();
        return Interpolation.linear;
    }
}

This is a feature request for a static function in the Interpolation class, that returns the appropriate instance of a built in interpolation type.

Version of LibGDX and/or relevant dependencies

1.9.10

Please select the affected platforms

  • Android
  • iOS (robovm)
  • iOS (MOE)
  • HTML/GWT
  • Windows
  • Linux
  • MacOS

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
NathanSweetcommented, Feb 15, 2020

I’d suggest to use a map, populate it with the interpolations you need (using reflection or anything else). IMO this is application level code, it doesn’t need to be in libgdx.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Feature request: String interpolation - Change Proposals
String interpolation must emit a series of delimiter tokens. It's no longer a single token, but you must have things like TokStringStart , ......
Read more >
feature request - conditional in string interpolation · Issue #4646
I've been burned by "Welcome, #{if user? then user.name}!" becoming “Welcome, undefined!” on more than one occasion. I like the idea of this....
Read more >
Email String Interpolation - Evaluate Variables withing HTML ...
I wanted to check if there inbuilt activity that does the simplifies email templating easily. Would automatically attempt to replace the ...
Read more >
String Interpolation in JavaScript - Dmitri Pavlutin
String interpolation is replacing placeholders with values in a string literal. Let's see in more detail, with examples and best practices, how ...
Read more >
String interpolation revamp: design decisions - Swift Forums
Although String doesn't care, many types want to treat them differently. The new design calls different methods for each one. New features: ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found