Why This Extension is not Compiling?

Thanks to you @vknow360

When you use the toArray or toStringArray methods the *list* element is dropped. This allows you to use 0-based indexing in Java like one would expect.

When returning a value, if you aren't planning to do sufficient type checking it is usually better to return a List<...> rather than a YailList. If you return List, the runtime will check it automatically to ensure that its contents are acceptable for the blocks language. If you return YailList, it is assumed you've taken the effort to check. This can lead to problems if you haven't sanitized the list data for the user.

4 Likes

I am trying to explain that use void instead of Yailist in

and you can take reference that @ewpatton said

What does that even do? You're not taking input whereas you're also not giving output...?

I had mistakenly left input..

In the case of output, you can use @SimpleEvent

Keep it simple as you can :grinning:

1 Like
@SimpleEvent(description = "")
public void GotItem(String item){
  EventDispatcher.dispatchEvent(this, "GotItem", item);
}

@SimpleFunction(description = "")
public void SelectItem(YailList list, int index){
  String item = "";
  item = (String) list.get(index);
  GotItem(item);
}

@AkshatRana is saying about this code... :slightly_smiling_face:

Yess... I was talking about this @Alpha2020 :slightly_smiling_face:

1 Like

The code is wrong. You should use get(INDEX) method for YailList.

See here-


https://www.w3schools.com/java/java_arrays.asp

1 Like

There are arrays and not list.

I didnt understand :thinking:

1 Like

Take a look here:

1 Like
item = (get[index]);

Should we use like this.

Use like this:

String item = (String) list.get(INDEX);
1 Like

Yess it can be!!

I have edited the code. See above

Is starts from 0 not 1

Anyone know how to fix this import in intelliij IDE??
image

it start from 1