[#79440] [Ruby trunk Bug#13188] Reinitialize Ruby VM. — shyouhei@...
Issue #13188 has been updated by Shyouhei Urabe.
6 messages
2017/02/06
[#79441] Re: [Ruby trunk Bug#13188] Reinitialize Ruby VM.
— SASADA Koichi <ko1@...>
2017/02/06
On 2017/02/06 10:10, shyouhei@ruby-lang.org wrote:
[#79532] Immutable Strings vs Symbols — Daniel Ferreira <subtileos@...>
Hi,
15 messages
2017/02/15
[#79541] Re: Immutable Strings vs Symbols
— Rodrigo Rosenfeld Rosas <rr.rosas@...>
2017/02/15
Em 15-02-2017 05:05, Daniel Ferreira escreveu:
[#79543] Re: Immutable Strings vs Symbols
— Daniel Ferreira <subtileos@...>
2017/02/16
Hi Rodrigo,
[#79560] Re: Immutable Strings vs Symbols
— Rodrigo Rosenfeld Rosas <rr.rosas@...>
2017/02/16
Em 15-02-2017 22:39, Daniel Ferreira escreveu:
[ruby-core:79659] [Ruby trunk Feature#13009] Implement fetch for Thread.current
From:
matz@...
Date:
2017-02-22 06:55:55 UTC
List:
ruby-core #79659
Issue #13009 has been updated by Yukihiro Matsumoto. OK. Matz ---------------------------------------- Feature #13009: Implement fetch for Thread.current https://bugs.ruby-lang.org/issues/13009#change-63076 * Author: David Butler * Status: Open * Priority: Normal * Assignee: Nobuyoshi Nakada * Target version: ---------------------------------------- It's a common idiom to use a fiber-local variable, but return a default value if it hasn't been assigned. Here's an example of Ruby code I would expect to be able to write: ~~~ ruby def feature_enabled? Thread.current.fetch(:feature_enabled, true) end ~~~ Unfortunately, Thread.current does not implement fetch, like Hash does. So I have to write the more verbose: ~~~ ruby def feature_enabled? Thread.current.key?(:feature_enabled) ? Thread.current[:feature_enabled] : true end ~~~ Thanks for your consideration! -- https://bugs.ruby-lang.org/ Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe> <http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>