If we try to analyze your question and in particular your case there are few important concepts.
def create_todo_lists(options={})
options={}
here signifies that if at all when calling this function no argument is passed, it will get a parameter named options
which will be an emty Hash.
create_todo_lists title: ""
in this line method create_todo_lists
is called without using parenthesis around, since parenthesis are optional in a Ruby method call, it's a valid syntax and is similar to
create_todo_lists(title: "")
- hash with single key value pair
In ruby a Hash with single key-value pair also has parenthesis optional therefore in your case
title: "" and {title: ""}
are similar.
- two different syntax for Hash
Ruby has two different syntax when using symbol as a Hash key therefore in your case
title: "" and :title => ""
are very much similar.
one more interesting concept in your scenario is
which is also pretty unique in Ruby.
This operator assigns right side value to left side variable only if value of left side variable is false
or nil
.
Therefore in your scenario create_todo_lists
method is getting a Hash as argument but covering few very important concepts of Ruby
.
Hope this helps. :)