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 - Unusual behaviour when drawing lots of images onto a large canvas -

how can i manage url using .htaccess in php? -

javascript - Chart.js - setting tooltip z-index -