// ❤️ 'self'

Posted by osxgirl on April 6, 2018

When self is called the class method will return it's self. When executing `puts "Human class method 'name' is #{Human.name}"` it will return the class Human in the output: `self is Human`.

This returned result of Human through the self is #{self} Human line call is called by the self.name method defined in the Human class. The returned result of self in `Human class method 'name' is heather haas` is outside of the method run so the return is the instance method – heather haas.

class Human
@@name = "heather haas"

def self.name
puts "self is #{self}"
return @@name
end
	
end

puts "Human class method 'name' is #{Human.name}"

self is Human
Human class method 'name' is heather haas

It’s good to know ones self