Hi guys, today I did this small test for the need of my project.
I would like to understand why the result is false ?
class Mother
def self.isDaughter : Bool
return self.class == Daughter
end
end
class Daughter < Mother
end
puts Daughter.isDaughter
Because self.class in the class scope of Mother is Class. You probably just want self == Daughter. But depending on your exact use case this may not work the way you think since a) you’re not working with instances here, and b) it won’t actually let the compiler narrow the type to Daughter instead of Mother if they were instances anyway.