On Wednesday, 30 August 2017 at 17:14:37 UTC, data pulverizer
wrote:
On Wednesday, 30 August 2017 at 16:45:19 UTC, data pulverizer
wrote:
You mentioned Julia in your article, however for clarity I
would point out that Julia doesn't have OOP-type polymorphism.
There is no notion of being able to do something like:
Animal snoopy = new Dog();
p.s. my bad, I was wrong about that! Turns out you can do
something like this in Julia (apologies for the Julia code in a
D forum):
abstract type Animal end
struct Dog <: Animal end
struct Cat <: Animal end
x = Array{Animal}(3)
x[1] = Cat(); x[2] = Dog(); x[3] = Cat();
x # returns
3-element Array{Animal,1}:
Cat()
Dog()
Cat()
p.p.s
typeof(x[1]) # returns Cat
so it isn't really polymorphism - the object is never converted
to the "parent" type! Lol ... sorry for the confusion!
Which is polymorphism