beanshell / beanshell

Beanshell scripting language
Apache License 2.0
815 stars 183 forks source link

How to create arrays from "scripted objects" #763

Open Raffa064 opened 1 month ago

Raffa064 commented 1 month ago

If i do something like:

` FakeClass() { prop = "Something"; return this; }

instance = FakeClass(); `

How can I create an array of this FakeClass?

nickl- commented 1 month ago

Your FakeClass is not a class but a function, method, or structure.

I am not sure how we can define arrays of scripted objects because they do not constitute a type.

You cannot for example say:

FakeClass instance = FakeClass();

Never thought about this before. Anyone else have any ideas?

opeongo commented 2 weeks ago

funcs = new Object[] { FakeClass(), FakeClass(), FakeClass() };

print( funcs[0].prop );