[#79440] [Ruby trunk Bug#13188] Reinitialize Ruby VM. — shyouhei@...
SXNzdWUgIzEzMTg4IGhhcyBiZWVuIHVwZGF0ZWQgYnkgU2h5b3VoZWkgVXJhYmUuCgoKTWFydGlu
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:79819] [Ruby trunk Feature#13260] Kernel#Boolean
From:
shevegen@...
Date:
2017-02-28 11:11:10 UTC
List:
ruby-core #79819
Issue #13260 has been updated by Robert A. Heiler.
> I think we have lots of occasions to receive a true or false value as a string input, and
> want to convert it to true or false.
I agree. :)
Not saying that I agree with the API, it feels a bit cumbersome; but I agree with the
comment above.
By the way, I think the first two cases are the one that are the least ambiguous
since they only evaluate the two strings "true" and "false" into the respective
true and false representation:
Boolean("true") # => true
Boolean("false") # => false
(The name "Boolean" is a bit strange though... where does this reside then? In
Kernel? Why not to_bool or to_boolean? Though admittedly the latter also includes
the word "boolean", I guess the uppercased leading part confuses me a bit. I am
aware of Kernel#Integer() or whever it resides, but I think that in general it
may be better to not use too many upcased method names; in ruby we have a lot of
flexibility like .Foo() or class Foo; Foo[] - but anyway, this is a side comment,
as written above I agree with what Tsuyoshi Sawada stated :) )
----------------------------------------
Feature #13260: Kernel#Boolean
https://bugs.ruby-lang.org/issues/13260#change-63255
* Author: Tsuyoshi Sawada
* Status: Feedback
* Priority: Normal
* Assignee:
* Target version:
----------------------------------------
I think we have lots of occasions to receive a `true` or `false` value as a string input, and want to convert it to `true` or `false`. Perhaps we can have a method `Kernel#Boolean` in a similar spirit to `Kernel#Integer` and its kins, which takes an optional keyword argument `exception` (similar to https://bugs.ruby-lang.org/issues/12732) and `strict` (defaulted to true).
```ruby
Boolean("true") # => true
Boolean("false") # => false
Boolean("foo") # => ArgumentError
Boolean("foo", exception: nil) # => nil
Boolean("1") # => ArgumentError
Boolean("1", strict: false) # => true
Boolean("yes", strict: false) # => true
Boolean("0", strict: false) # => false
Boolean("no", strict: false) # => false
Boolean("foo", strict: false, exception: nil) # => nil
```
--
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>