[#66126] Creation/Conversion methods/functions table for Ruby types — SASADA Koichi <ko1@...>
Hi,
5 messages
2014/11/07
[#66248] [ruby-trunk - Feature #10423] [PATCH] opt_str_lit*: avoid literal string allocations — normalperson@...
Issue #10423 has been updated by Eric Wong.
3 messages
2014/11/13
[#66595] [ruby-trunk - Bug #10557] [Open] Block not given when the argument is a string — bartosz@...
Issue #10557 has been reported by Bartosz Kopinski.
3 messages
2014/11/30
[ruby-core:66107] [ruby-trunk - Feature #10378] [PATCH 0/3] It's better (1 + 0i).real? return true
From:
mail@...
Date:
2014-11-05 21:40:01 UTC
List:
ruby-core #66107
Issue #10378 has been updated by gogo tanaka.
@Takeshi Nishimatsu san
OK, it does make sense. thanks.
----------------------------------------
Feature #10378: [PATCH 0/3] It's better (1 + 0i).real? return true
https://bugs.ruby-lang.org/issues/10378#change-49819
* Author: gogo tanaka
* Status: Open
* Priority: Normal
* Assignee:
* Category: core
* Target version: current: 2.2.0
----------------------------------------
Right now, `Complex#real?` return `false` anytime.
I suppose `#is_a?(Complex)` is enough to check whether a object is `Complex`'s object or not.
(I have to admire `#real?` is more useful than `#is_a?(Complex)`)
But what we really want to know is whether a object whose class has `Numeric` as superclass is equal to real number or not.
Actually whichever is ok, modifying `#real?` or implementing as new method(e.g #real_num? ... :(
Anyway, I wanna method like that for `Complex`.
```cpp
static VALUE
nucomp_real_p(VALUE self)
{
get_dat1(self);
if (rb_equal(dat->imag, INT2FIX(0))) {
return Qtrue;
}
return Qfalse;
}
```
By the way, I can find two coding styles through ruby source code.
Which is prefer? it doesn't matter?
```cpp
if(...)
return ...
retrun ...
```
or
```cpp
if(...) {
return ...
}
retrun ...
```
---Files--------------------------------
update_NEWS.patch (716 Bytes)
add_tests.patch (848 Bytes)
update_Complex#real_.patch (1.18 KB)
--
https://bugs.ruby-lang.org/