[#23231] What do you think about changing the return value of Kernel#require and Kernel#load to the source encoding of the required file? — =?ISO-8859-15?Q?Wolfgang_N=E1dasi-Donner?= <ed.odanow@...>

Dear Ruby developers and users!

8 messages 2009/04/17

[#23318] [Feature #1408] 0.1.to_r not equal to (1/10) — Heesob Park <redmine@...>

Feature #1408: 0.1.to_r not equal to (1/10)

19 messages 2009/04/26

[ruby-core:23238] Re: [Bug #1387] first(0) and last(0) behavior

From: Jeremy Kemper <jeremy@...>
Date: 2009-04-17 16:25:08 UTC
List: ruby-core #23238
On Fri, Apr 17, 2009 at 11:03 AM, Dave B <redmine@ruby-lang.org> wrote:
> Issue #1387 has been updated by Dave B.
>
>
> Those methods (for String) don't exist in Matz Ruby:
>
> puts 'ruby %s (%s) [%s]' % [RUBY_VERSION, RUBY_RELEASE_DATE, RUBY_PLATFORM]
>
> p "abc".first(1)
>
> #ruby 1.8.6 (2008-08-11) [i386-mswin32]
> #tmp:3: undefined method `first' for "abc":String (NoMethodError)
>
> # ... neither in 1.9.1 ...
>
> #ruby 1.9.1 (2009-01-30) [i386-mswin32_90]
> # tmp:3:in `<main>': undefined method `first' for "abc":String (NoMethodError)
>
> A quick search finds they are added by Rails but maybe you have
> some other library which adds the methods.
> http://errtheblog.com/posts/42-rails-rubyisms-advent
>
> Either way, if you can't track them down, try asking on either
> the ruby-talk or Rails lists.

In Rails, String#first is self[0..(n-1)], so "abc".first(0) ==
"abc"[0..-1] == "abc"

Changing this to self[0...n] would satisfy your expectation: "abc"[0...0] == ""

Please submit a patch to Rails :)

jeremy

In This Thread

Prev Next