Advertisement
Guest User

Untitled

a guest
Jan 24th, 2017
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Rails 0.38 KB | None | 0 0
  1. irb(main):001:0> no_of_customers = 3
  2. #=> 3
  3. irb(main):002:0> no_of_customers == 1 ? (customer_noun = "customer") : (customer_noun = "customers")
  4. #=> "customers"
  5. irb(main):003:0> puts "#{no_of_customers} #{customer_noun}."
  6. #=> 3 customers.
  7.  
  8. # Did you know that in Ruby on Rails you can simply write this, instead?
  9. puts "#{no_of_customers} #{"customer".pluralize(no_of_customers)}."
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement