[#1579] arity bug? — "Christoph" <chr_news@...>
Hi,
5 messages
2003/10/05
[#1588] FreeBSD problem with processes — Laurent Sansonetti <pinux@...>
Hi all,
1 message
2003/10/07
[#1591] Re: Yielding to a block from a proc? — george.marrows@...
> > Is this right? Is this pathological? Is it a bug? Is there
6 messages
2003/10/08
[#1596] PATCH: Revive NextStep, OpenStep, Rhapsody ports — Eric Sunshine <sunshine@...>
Hello,
7 messages
2003/10/09
[#1597] Re: PATCH: Revive NextStep, OpenStep, Rhapsody ports
— matz@... (Yukihiro Matsumoto)
2003/10/09
Hi,
[#1600] CVS access — Sean Russell <ser@...>
Hiya,
8 messages
2003/10/09
[#1611] set_trace_func/Array#fetch error — "Nathaniel Talbott" <nathaniel@...>
I've reduced the error I reported in ruby-talk:84013 to the following code:
17 messages
2003/10/11
[#1612] Re: set_trace_func/Array#fetch error
— ts <decoux@...>
2003/10/11
>>>>> "N" == Nathaniel Talbott <nathaniel@talbott.ws> writes:
[#1616] Re: set_trace_func/Array#fetch error
— "Nathaniel Talbott" <nathaniel@...>
2003/10/11
ts [mailto:decoux@moulon.inra.fr] wrote:
[#1617] Re: set_trace_func/Array#fetch error
— ts <decoux@...>
2003/10/11
>>>>> "N" == Nathaniel Talbott <nathaniel@talbott.ws> writes:
[#1618] Re: set_trace_func/Array#fetch error
— "Nathaniel Talbott" <nathaniel@...>
2003/10/11
ts [mailto:decoux@moulon.inra.fr] wrote:
[#1634] stringy range bug — "Christoph" <chr_news@...>
Hi,
6 messages
2003/10/15
[#1640] SystemStackError in embedding — Sentinel <sentinel27@...>
Hi, I am just now trying to embed ruby into my apprication
8 messages
2003/10/18
Re: set_trace_func/Array#fetch error
From:
"daz" <dooby@...10.karoo.co.uk>
Date:
2003-10-11 20:59:06 UTC
List:
ruby-core #1619
From: "ts" <decoux@moulon.inra.fr>
> >>>>> "d" == daz <dooby@d10.karoo.co.uk> writes:
>
> >> def m
> >> [].fetch(2) {return nil}
>
> d> [].fetch(2) {nil} # <--------- see Array#fetch w/ block
>
> No, no : this is volontary. See lib/optparse.rb
>
> def search(id, key)
> if list = __send__(id)
> val = list.fetch(key) {return nil}
> return val unless block_given?
> yield(val)
> end
> end
>
>
>
> Guy Decoux
>
>
Understood (took me a while).
No assignment is being made to val when
the index lies outside the array.
The 'nil' after 'return' in the optparse.rb clip
isn't strictly necessary.
<Pickaxe>
"A return expression immediately exits a method.
The value of a return is nil if it is called with
no parameters, ..."
</>
(sounds obvious but, inside a block, it made me
think of different scope.)
<ri> Array#fetch
... the [block] form returns the value of invoking
the block, ...
</>
self.note("That use of the verb 'return' is not\
related to the ruby keyword 'return' !!!")
def roo(n)
ret = ['A'].fetch(n) {return}
puts "ZZZ#{n}"
ret || 42 # never nil
end
p roo(0)
p roo(1)
#-> ZZZ0
#-> "A"
#-> nil
Thanks,
rosbif ;)
(Can't think of an occasion in 14 months when I
couldn't understand the anglois. Continuez svp)