Typecast working and not working
Monkey Forums/Monkey Programming/Typecast working and not working
| ||
Hi friends! See this code below: If (ac <> Null) If (Not Enemy(ac).medo) dieSound.Play() ac.MoveStart() KillMe() Else ac.MoveStart() Enemy(ac).medo = False jogo.score += 100 End End Im typecasting if (Not Enemy(ac).medo) and its working but its give me error on the Enemy(ac).medo = false line. How can it works on a line and not work on another? Edit: Its a problem with demo version not full. Thanks! |
| ||
The demo is totally outdated and will give a wrong impression what you can do with the language and what not. |
| ||
is this a bug?Strict Class hi Field trev:Int End Class Function Main:Int() Local f:hi If hi(f) Print "true" Else Print "its not a hi" Endif End Function it prints 'its not a hi" |
| ||
no because it doesn't work as what you think. It produces the address of the instance if it has been instantiated as the casting class or 0(null) if it has not. and of course you know that 0 or Null equals false. |
| ||
Create the instance, then it works.Local f:hi = New hi |