Ruby gotchas
I figure we should all be aware of these:
- and / or is NOT the same as && / ||
- eql? is NOT the same as == (and NOT the same as equal? or ===)
- super is NOT the same as super()
- Your exception must not be an Exception
- class Foo::Bar is NOT the same as module Foo; class Bar
- Most bang! methods return nil when they do nothing
- attribute=(value) method always returns passed value, regardless of method return value
- private will NOT make your self.method private
I personally didn’t know the
attribute=
one. I hope this helps fill out our shared Ruby knowledge.