You can build this more generically as well. For example, if you make BigCat<:HouseCat, then put anything which extends HouseCat via composition, then you can use
type Tiger <: BigCat hcat::HouseCat #Inheritance by composition end meow(c::BigCat) = println(c.hcat.age)#Define a method to make it seamless This will work for every BigCat. You can then define a macro to make a bunch of dispatches like this. On Thursday, September 1, 2016 at 9:38:13 AM UTC-7, Michael Borregaard wrote: > > To do something like this in Julia, there are several possibilities, > depending what you want to achieve. You could > > abstract Cat # we decide hat cat will always have an age variable > > type Tiger <: Cat > age::Int > end > > meow(c::Cat) = println(c.age) > > # then you can > tigre = Tiger(5) > meow(tigre) > > >
