Quantcast
Channel: SCN: Message List
Viewing all articles
Browse latest Browse all 9159

Re: doubts in narrow casting

$
0
0

Hi,

*call method o_super->m4.  "throws syntax error.


but when i change this to m4 in brackets:

call method o_super->('m4'). "works fine WHY!!!!!! (atleast no syntax error)


but the prog dumps.

Basically what is the diff between two above statements.

 

What you have written by adding brackets is a dynamic method call. Syntax checker is is no run-time environment and the correctness of dynamic method call will not be evaluated until run-time... That's why syntax error goes away, and run-time error comes.

 

And, obviously, nothing in the call is working "fine". If you will change the call to call method o_super->('M4')and will not overwrite o_super by recreating it from static type vehicle, the call indeed will work fine For the difference between static access and dynamic access read Accessing Class Components please.

 

cheers

Jānis


Viewing all articles
Browse latest Browse all 9159

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>