|
|
|
|
|
by edtechdev
4023 days ago
|
|
[0; 'a'; fun x -> x + 1];; The common type is object, or perhaps more specifically, non-nil object (object!), if 0 is not treated as nil (value type). If you try to interact with an object (add it to a number, call a method, etc.), your language has to decide what to do: fail because that method is not part of the type object, or force people to cast to the proper sub-type, or allow a kind of dependent typing/casting (if type(it)=int: it+1 else if type=char: it.uppercase), or (like boo, python, ruby, etc.) allow "duck typing": allow any calls/methods on the object, and check it at run-time instead of compile-time |
|