A
A
anasasiakiri4enko2016-06-02 19:29:49
Ruby on Rails
anasasiakiri4enko, 2016-06-02 19:29:49

Ruby syntax parsing?

Good afternoon.
I'm confused with the syntax, help me figure it out!
In rails I often see the syntax: name1 - This is the function to which the parameter is passed name2 - the hash passed to the function name1 name3 is the character that is in the hash. Is it so? Do I understand correctly? Explain colon declarations - I'm confused about them. name1 name2: :name3

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andrey Demidenko, 2016-06-02
@anasasiakiri4enko

name1 - this is the name of the method, everything is correct, but its parameter is hash
name2: - key
:name3 - value
Calling is equivalent to Symbolname1({name2: :name3})
begins with a colon If you use the old hash syntax, it might be clearer
name1({:name2 => :name3})

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question