Not sure if I can do this in Xojo, but thought I’d ask: is there a way to do a single-line initialization of an array that contains objects?
Example: I have a class “foo” with two properties, “bar” and “bar2” and a constructor New(b1, b2)
Can I do this:
dim tardis() as foo = array(new foo(“fee”, “fi”), new foo(“fo”, “fum”))
The compiler appears not to like that syntax. Is there an accepted way of doing this, other than putting each element of the array in manually on a new line of code?
That line of code works for me. What is the compilers complaint?
D’oh! Sorry for the erroneous post. It does, indeed work. I was bitten by one of those many instances in which I type a string into the inspector, then tab out of the field, and the property doesn’t “take.” This happens to me all the time. I have to remember to manually click out (and sometimes back into) method names, parameter definitions, and object names.
Anyway, thank you Will, it does, in fact, work as I had originally posted.
Nothing to see here. Move along.