1. Ruby Quicktips: Convert anything to boolean →

    Just add !! (a.k.a. the double bang operator) before any statement:

    >> @document = Document.new
    => <Document id: nil, title: nil> >> @document.title
    => nil
    >> !!@document.title
    => false >> @document.title = "My new document"
    >> !!@document.title
    => true
    

    In Rails, you can use the name of your…

Notes

  1. djocubeit reblogged this from rubyquicktips
  2. sanemat reblogged this from rubyquicktips
  3. rubyquicktips posted this