Slides
Sending a message by name
equivalent:
cookie.bake cookie.send(:bake) method_name = "bake" cookie.send(method_name) ```
Duping and freezing and cloning
-
dupmakes a copy of the object's data, so you can change it without affecting the original -
freezemakes it so when you try to modify an object, it raises an exception instead -
cloneis likedup, but cloning a frozen object freezes the new clone too- also
clonecopies the singleton methods
- also
>> cookie.methods(false)
=> [:bake, :yell]
>> cookie.clone.methods(false)
=> [:bake, :yell]
>> cookie.dup.methods(false)
=> []