Synthead,

Yup :) Everything in Ruby inherits Object, too. It’s a really neat language, and when you get accustomed to it, you might wonder why some other languages aren’t written like it.

For the 0 value being truthy, consider that Ruby is a dynamic language. Imagine if you asked a user how many motorcycles they own. If they answer, you’ll have an Integer. If they don’t, you’ll have nil, from NilClass. 0 is just as valid of an answer as 2, so you can do something like this:


<span style="color:#323232;">raise NoResponse unless motorcycles
</span><span style="color:#323232;">
</span><span style="color:#323232;">save_motorcycles(motorcycles)
</span>
  • All
  • Subscribed
  • Moderated
  • Favorites
  • random
  • uselessserver093
  • Food
  • [email protected]
  • aaaaaaacccccccce
  • test
  • CafeMeta
  • testmag
  • MUD
  • RhythmGameZone
  • RSS
  • dabs
  • oklahoma
  • Socialism
  • KbinCafe
  • TheResearchGuardian
  • SuperSentai
  • feritale
  • KamenRider
  • All magazines