What does the operator "|| =" do in ruby?

Possible duplicate:
What does || = in Ruby?

I am new to ruby ​​and I saw that this is used in one of the answers here:

RACK_ENV = ENV['ENVIRONMENT'] ||= 'test'

I could not find a link to the operator ||=...

0
source share
2 answers

what makes || do? If you have a and b, then it a || bis true if and only if a or b is true. Same thing with || = This operator combines two operations: "=" and "||". So a ||= bequivalentlyc || c = b

EDIT: ENV ['ENVIRONMENT'] || = 'test' , ENV ['ENVIRONMENT'] , false, , "" ENV ['ENVIRONMENT'] RACK_ENV

-2

, .

"Ruby, concurrency,... | | ..." Ruby T-Square. 14 2008 .   "|| =" , , , . , . ..

a || = expr

a = a ||

a = expr

, , [0]

DTrace script , - ( - Ruby) . , , , "OR'ing":

"Ruby Boolean- : , & &. Ruby true false, Boolean.. , ".

.,

" , Ruby Boolean , , , " ". lefthand, ".

https://blogs.oracle.com/prashant/entry/the_ruby_t_square_operator

+1

All Articles