"o = Foo(); o.nonstandardattribute = bar"
this can't be done.
attributes in ruby are set via setter methods
class Foo def std_attr= v @std_attr = v end end
although the simpler way to do it is
class Foo attr_writer :std_attr end
what "An instance of a class can be extended to be subtly different, without needing to subclass" actually means is
s = 'a string' class << s def consonants gsub /[aeiou]/i, '' end end
s.consonants will give you " strng", but on any other string, it'll raise an undefined method error.