index parameters on properties

Posted by jmls on 28-Oct-2008 10:16

In a moment of madness, I wondered what would happen if I declared a property as an extent. Well, slap me with a kipper, it worked !

[1,2,3,4,5][p_Index]

Was this documented anywhere ?? It's a great feature

All Replies

Posted by jmls on 28-Oct-2008 10:35

The question has to be asked: Are there any other little hidden gems that have not been documented thus far ?

Posted by sarahm on 28-Oct-2008 10:47

Glad it's working for you. This was implemented in 102a, so you didn't have it prior to the beta.

Posted by jmls on 28-Oct-2008 10:49

Glad it's working for you. This was implemented in

102a, so you didn't have it prior to the beta.

Yeah, I tried it in 10.1B and then 10.1C when I upgraded. I just tried it again on the off-chance And it worked !

cue celebrations ...

Posted by Thomas Mercer-Hursh on 28-Oct-2008 11:40

Myself, I'd prefer to eat the kipper, but each to their own taste, I guess ...

The question is, why did you want to do it? What do you do with arrays?

Posted by jmls on 28-Oct-2008 11:47

Myself, I'd prefer to eat the kipper, but each to

their own taste, I guess ...

Mine's the salmon, then ..

The question is, why did you want to do it? What do

you do with arrays?

In this case, I was trying to get / set the properties of the nth entry in the colour table. Rather than having to hard-code the max number of entries, and having to manually define Colour1, Colour2, Colour3 etc, I wanted to do it with less code .. this way I can say

[x]

instead of

Yes, I could do this with a method, but I don't like having to use methods instead of properties, and the code looks better

Arrgh. the [] doesn't like an i

Message was edited by:

Julian Lyndon-Smith

Posted by Admin on 28-Oct-2008 11:50

Was this documented anywhere ?? It's a great feature

Looks cool. Does this work with variable length arrays as well?

Posted by jmls on 28-Oct-2008 12:17

Looks cool. Does this work with variable length

arrays as well?

Looks like it does

[1,2,3,4,5][p_Index]

def var a as experimental.array.

a = new experimental.array().

a:FooSize = 5.

message a:foo[1]]> ]]>

This thread is closed