Railo can do array notation from method calls


Railo can do array notation from method calls

Posted by Luis Majano
Apr 06, 2009 00:00:00 UTC
I just found out about this by trying it out and thought wow, FINALLY!

Let's say I have a method that returns an array. Example below:

As you can see, a very simple example. So now, in my code outside my method I want to be able to access let's say item number 3 from the method call and the key called awesomeLevel from the structure call. Then I can do this:

item3 = getArray()[3];

MyAwesomeLevel = getStruct()['awesomeLevel'];

How cool is that, finally!! Array syntax from method calls.


radekg

Now that is cool. I'm curious how long it will take adobe to implement that.

Ben Nadel

That is awesome. Yeah, Adobe has to upgrade the way they handle some compile time stuff.

Tony Garcia

I've noticed that you can use dot notation to get struct key values from a method call in CF (example: getStruct().awesomeLevel), but it's a no-go with bracket notation, like with Railo

Aaron Greenlee

It makes perfect sense. I've not yet had a use for something like this, but, I am suprised it was not implemented by the other engines before.

Aaron West

That's sorta / kinda confusing (parens then square brackets) but definitely useful if you know it's there.

Matt Williams

I find myself using similar syntax in javascript: id = myString.split('_')[1];