Object to array cast?

BlitzMax Forums/BlitzMax Programming/Object to array cast?

Otus(Posted 2007) [#1]
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



tonyg(Posted 2007) [#2]
Is it so you can do this
SuperStrict

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.


Grey Alien(Posted 2007) [#3]
Bit of useful polymorphism which would allow you to store different object types in the array I guess.


Otus(Posted 2007) [#4]
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.


Grey Alien(Posted 2007) [#5]
Does it make and array with one slot which points to the object?


Otus(Posted 2007) [#6]
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.


Grey Alien(Posted 2007) [#7]
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...