Object to array cast?
BlitzMax Forums/BlitzMax Programming/Object to array cast?
| ||
Found this under changes to some earlier version. What does it mean? "+ (BCC) Fixed Object to array cast not returning an array of references." This code, curiously enough, works. Although it doesn't do anything. SuperStrict Framework BRL.Basic Type TTest Field value:Int End Type Local t1:Object = New TTest Local t2:Object = t1 Local tarray:Object[] = Object[](t1) 'Hmm? DebugStop |
| ||
Is it so you can do thisSuperStrict Framework BRL.Basic Type TTest Field value:Int End Type Local t1:ttest = New TTest t1.value=5 Local tarray:Object[5] tarray[0] = Object(t1) 'Hmm? Print ttest(tarray[0]).value Not sure when I would do it. |
| ||
Bit of useful polymorphism which would allow you to store different object types in the array I guess. |
| ||
No, I think you missed the point. In my code Object[](t1) attempts to cast an object into object array, and for some reason succeeds. I'm wondering what it is all about. |
| ||
Does it make and array with one slot which points to the object? |
| ||
I'm not sure what it does. In my test it returned Null, but "+ (BCC) Fixed Object to array cast not returning an array of references." made me wonder if it should do something. |
| ||
Maybe it used to do something bad/improper and now it's been made "safe" but you'd think there'd be a compile error if it wasn't supposed to happen... |