I'm still a beginner trying to understand how I can return a value through helper blocks
I make simple extension to understand it but it doesn't work
@SimpleFunction
public int plus(@Options(Numbers.class) int num1,@Options(Numbers.class) int num2) {
return num1 + num2;
}
' Numbers Class '
public enum Numbers implements OptionList<Integer> {
one(1),
@Default
two(2),
three(3),
four(4),
five(5),
six(6),
seven(7),
eight(8),
nine(9),
@Deprecated
ten(10);
private int number;
Numbers(int num) {
this.number = num;
}
@Override
public Integer toUnderlyingValue() {
return number;
}
}
And i want to know what is the benfit of that code
private static final Map<String, Animal> lookup = new HashMap<>();
static {
for(Animal anim : Animal.values()) {
lookup.put(anim.toUnderlyingValue(), anim);
}
}
public static Animal fromUnderlyingValue(String anim) {
return lookup.get(anim);
}
}
I took it from How to Add a Dropdown Block to a Component - Google Docs