Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Review: Metaprogramming in ES6: Symbols and why they're awesome
class BoringClass  
end  
class CoolClass  
  def ==(other_object)
   other_object.is_a? MyClass
  end
end  
BoringClass.new == BoringClass.new #=> false  
CoolClass.new == CoolClass.new #=> true!  
  • Seems like that MyClass should be CoolClass
  • I always prefer realistic examples

Symbol('foo') !== Symbol('foo'); // true!

I'd rather see that as

Symbol('foo') === Symbol('foo'); // false!

Near the beginning of the material about symbols, I could use a numbered list of use cases driving the addition of symbols. Eventually it's clear after reading the lengthy descriptions of what the do, what they don't do, and how they integrate for operator overloading type scenarios, but at the beginning I didn't have a good set of mental boxes to be filled so the information just piles up disorganized in my short-term memory.

The back story on Symbol.unscopables is good context.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.