My extension is compiling but after use in app,it is showing runtime error

I was currently working to build my next extension ArrayFunctions.
While making block of removing an item from the list, first I take Yailist list from the user then I converted it into String array then I converted that String array to Array list to perform remove. It is finely compiling with no problem but it is not performing any task in-app and giving an error:
Here is my code:

@SimpleFunction(description=“Remove element from index.It pass the list.”)
//At first i take a input of list and position from user
public YailList RemoveElementFromPosition(YailList list,int position){
//Then i converted it into the String array
String arraylist=list.toStringArray();
//Then i converted this String array to Array list to perform the remove function
List listcopy=Arrays.asList(arraylist);
//Then i remove the element in position -1 whcih is index
listcopy.remove(position-1);
//Then i again converted the array list to array so that i can change it into Yailist
Object arrayout=listcopy.toArray();
//At last i returned the list by converting the array into the Yailist.
return YailList.makeList(arrayout);

The error is like that:
image

Here is my extension:com.appybuilder.mailtoosea.Testonly.aix (5.3 KB)

List does not support removing objects.
So convert YailList into ArrayList.

2 Likes

As said use this code to convert yail list named list to array named arrayer

@SimpleFunction
    public void example(YailList list) {
        String[] arrayer = new string[list.size()];
        int index = 0;
        for(String e : list.toStringArray()) {
            arrayer[index] = e;
            index++;
        }
    }

Now in the variable called arrayer you have the value.

@HIFI_APPS what result will the arrayer return?

You're parsing them to Integer. If you put a list with characters then you will get an error.

2 Likes

@oseamiya you must not use list if you are using integers in your extension

edited post

Only example it will convert not return

How can you save String data in int array :sweat_smile: :laughing:

1 Like

Please test you're code before posting it.

2 Likes

I can't in mobile but re edited

Again :sweat_smile:. How can you assign int array value to string array? :laughing: :expressionless:

2 Likes

Array and ArrayList are different.
This should work fine:

List list = new ArrayList<>();
String[] sArray = yailList.toStringArray();
for (String s:sArray){
  list.add(s);
}
list.remove(index - 1);//now you can add and remove items
2 Likes
@SimpleFunction
    public void Example(YailList list) {
        Object[] arrayer = new Object[list.size()];
        int index = 0;
        for(Object e : list.toArray()) {
            arrayer[index] = e;
            index++;
        }
    }

Try this for all type of things to array

The object must be Object

Hmm, @HIFI_APPS it's better if you use a laptop :confused:

1 Like

@HIFI_APPS Think you need to learn more :confused:

2 Likes

btw, what's the point of adding index++

@vknow360 i edited yes will it work

List list = new ArrayList<>();
Object[] sArray = yailList.toArray();
for (Object s:sArray){
  list.add(s);
}

And

(String) s

To convert to string ...

#Off topic
Yes I need to learn actually I copy pasted
Ur post

...