< :前の番号
^ :番号順リスト
> :次の番号
P :前の記事(スレッド移動)
N :次の記事
|<:前のスレッド
>|:次のスレッド
^ :返事先
_:自分への返事
>:同じ返事先を持つ記事(前)
<:同じ返事先を持つ記事(後)
---:分割してスレッド表示、再表示
| :分割して(縦)スレッド表示、再表示
~ :スレッドのフレーム消去
.:インデックス
..:インデックスのインデックス
Following a discussion on ruby-talk of a few ideas for ruby[1],
thought I'd suggest them (one at a time) to core.
Here's the first.
Add an Object#in? method to complement Enumerable#include?
Background: currently if you want to test for membership you have to
do it "backward" by using include? on the array.
ex:
if STUFF.include?(a)
puts 'yes'
else
puts 'no'
end
Clearer to the reader (at least to my eyes) would be
if a.in?(STUFF)
puts 'yes'
else
puts 'no'
end
proposed definition (from [3])
module Kernel
# Is self included in other?
#
# 5.in?(0..10) #=> true
# 5.in?([0,1,2,3]) #=> false
#
def in?(other)
other.include?(self)
end
end
currently several developers said they use this idiom already [1,2,3],
facets has it, and I have found it quite useful in the past, therefore
propose its incorporation into core.
drawbacks: existing 'in?' methods would become ambiguous--I'd imagine
this is rare so hopefully a limited impact.
Thoughts?
Thanks.
-=r
[1] http://www.ruby-forum.com/topic/184011
[2] http://snippets.dzone.com/posts/show/3516
[3] http://facets.rubyforge.org/doc/api/core/classes/Kernel.html#M000425