Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ruby on Rails: what does "equals" symbol mean as a parameter?

Some open source I've been using has the below line as a function declaration:

def parse_query(query=nil, options={}, models=nil)

What effect do the "equals" symbols have on the statement? Does it just make the parameters optional?

like image 570
happythenewsad Avatar asked Jun 10 '09 15:06

happythenewsad


People also ask

What does |= mean in ruby?

Ruby has an or-equals operator that allows a value to be assigned to a variable if and only if that variable evaluates to either nil or false .

What is a parameter in ruby?

What is a parameter? Parameters in ruby are variables that are defined in method definition and which represent the ability of a method to accept arguments. So, if we will not have the appropriate parameters, then we will not be able to pass arguments to a method that will contain the data we need.


1 Answers

It sets the default value of the parameter, if the person calling the function does not specify one.

like image 105
Oliver N. Avatar answered Oct 24 '22 21:10

Oliver N.