About a year ago, programmer Tony Arcieri posed a question on the Ruby language bug tracker: Why was Thread.exclusive deprecated?
Among the answers to this question, Shyouhei Urabe’s one of the tersest feature descriptions yet: “we already have such thing, to some extent at least”:
/#{@mutex=Mutex.new}/o
- The pair of slashes are Regular Expression delimiters.
- A Regular Expression in Ruby allows String interpolation, just like the double-quoted String does. The
#{}
contains interpolated Ruby code. - The modifier
o
at the end of the Regular Expression stands for “once”. So, the regex engine would keep track of this replacement, and do it just once.
The Malmo.rb named this expression (//o
) the face-palm operator.