Class Struct gives us many more methods than Class. In this example we look at members(). class BoatOne   attr_accessor :name, :loa   def initialize(name, loa) @name = name @loa = loa end   end   BoatTwo = Struct.new(:name, :loa)   # Class Struct puts BoatTwo.new("albondigas", 45) puts BoatTwo.new("albondigas", 45).members   # Class BoatOne puts BoatOne.new("trout", 32).inspect puts BoatOne.new("trout", 32).members

Today we look at basic Ruby object model inheritance. class Vessel   def cargo {} end   def capacity raise "Capacity not defined on vessel" end   end   class SmallCraft < Vessel   def cargo { life_jackets: true, gasoline: true } end   end   vessel = Vessel.new small = SmallCraft.new puts vessel.cargo puts small.cargo puts small.capacity   #=> {} #=> {:life_jackets=>true, :gasoline=>true} #=> hash_mutation.rb:8:in `capacity’: Capacity not defined on vessel (RuntimeError) from hash_mutation.rb:28:in `<main>’

In Ruby when inheriting class beware of the expected value of self. The following example illustrates this caveat. class Log def self.priority Log.new(priority: true) end end   class Fishing < Log end   >> Fishing.priority => <#Log … > But… if you declare self.new the class with inherit from current class.   class Log def self.priority self.new(priority: true) end end   class Fishing < Log end   >> Fishing.priority #=> <#Fishing … > :)