Difference between asInstanceOf[ ] and isInstanceOf[ ] in scala -


what difference between asinstanceof[] , isinstanceof[]?

generally speaking, a.asinstanceof[b] performs actual cast: takes object of type , returns (if possible) object of type b, whereas a.isinstanceof[b] returns boolean indicating whether a has type b or not.

strictly speaking isinstanceof[b] looks not if of type b, if has type b in upper side inheritance tree (so if b superclass of a, isinstanceof yield true) , important notice isinstanceof works on actual object type hierarchy rather on reference type.


Comments

Popular posts from this blog

javascript - Count length of each class -

What design pattern is this code in Javascript? -

hadoop - Restrict secondarynamenode to be installed and run on any other node in the cluster -