Jump to content

The ultimate community for Ruby on Rails developers.


Photo

If the method and computes something and returns a boolean. Need postfix "?" ?

Rails Ruby

  • Please log in to reply
1 reply to this topic

#1 Lucky_Alexx

Lucky_Alexx

    Passenger

  • Members
  • 5 posts

Posted 15 November 2016 - 04:48 PM

If the method and computes something and returns a boolean. Need postfix "?" ?

My be postfix "!"



#2 Ohm

Ohm

    Driver

  • Moderators
  • 529 posts
  • LocationCopenhagen

Posted 15 November 2016 - 07:20 PM

That is totally up to you, but the norm is to put a ? after a method that returns a boolean (and asks a question)

 

Normally, in other programming languages, you'd see is_active, however in Ruby we write active? instead.

def active?
  alive? && well?
end

Blog: http://ohm.sh | Twitter: @madsohm | Work: Lokalebasen.dk






Also tagged with one or more of these keywords: Rails, Ruby

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users