is it possible to make a quick "double assignation " in a hash like in
php, for example :
a={}
a[:b][:c]=“value”
is it possible to make a quick "double assignation " in a hash like in
php, for example :
a={}
a[:b][:c]=“value”
I don’t think so… why would you want to though? It’s not that much
more code to say
value = whatever_intecate_algorithm_or_calculation_you_need
a[:b] = value
a[:c] = value
or
a{ a=> value, b => value}
On Jun 4, 7:10 pm, nico Itkin [email protected]
nico Itkin wrote:
is it possible to make a quick "double assignation " in a hash like in
php, for example :a={}
a[:b][:c]=“value”
it’s actually
a = {}
=> {}a[:a] = a[:b] = 1
=> 1a
=> {:a=>1, :b=>1}
script/console is your friend
Peace,
Phillip
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs