What is the difference between map and collect?
There is none, collect is an alias for map in ruby. They both invoke a block once for each element in ‘self’. Eg:
xyz.collect { |x| x * 2 }Whats the ternary operator in rails?
Its a one line ifelse statement statement
@item.property = params[:property] ? true : false
for example
var = 5;
var_is_greater_than_three = (var > 3 ? true : false);
puts var_is_greater_than_three
The values true and false can be replaced with strings, numbers, or other data types.
What is ‘self’ in ruby?
Its a keyword that gives you access to the current object.