60件ヒット
[1-60件を表示]
(0.256秒)
種類
- インスタンスメソッド (50)
- 定数 (10)
キーワード
- DATA (10)
-
enum
_ for (20) -
respond
_ to? (10) -
to
_ enum (20)
検索結果
先頭5件
-
Object
# enum _ for(method = :each , *args) -> Enumerator (8125.0) -
Enumerator.new(self, method, *args) を返します。
...数です。
//emlist[][ruby]{
str = "xyz"
enum = str.enum_for(:each_byte)
p(a = enum.map{|b| '%02x' % b }) #=> ["78", "79", "7a"]
# protects an array from being modified
a = [1, 2, 3]
p(a.to_enum) #=> #<Enumerator: [1, 2, 3]:each>
//}
//emlist[例(ブロックを指定する場合)][ruby]{
modu......_method__, n) do
# size メソッドが nil でなければ size * n を返す。
sz = size
sz * n if sz
end
end
each do |*val|
n.times { yield *val }
end
end
end
%i[hello world].repeat(2) { |w| puts w }
# => 'hello', 'hello', 'world', 'world'
enum... -
Object
# enum _ for(method = :each , *args) {|*args| . . . } -> Enumerator (8125.0) -
Enumerator.new(self, method, *args) を返します。
...数です。
//emlist[][ruby]{
str = "xyz"
enum = str.enum_for(:each_byte)
p(a = enum.map{|b| '%02x' % b }) #=> ["78", "79", "7a"]
# protects an array from being modified
a = [1, 2, 3]
p(a.to_enum) #=> #<Enumerator: [1, 2, 3]:each>
//}
//emlist[例(ブロックを指定する場合)][ruby]{
modu......_method__, n) do
# size メソッドが nil でなければ size * n を返す。
sz = size
sz * n if sz
end
end
each do |*val|
n.times { yield *val }
end
end
end
%i[hello world].repeat(2) { |w| puts w }
# => 'hello', 'hello', 'world', 'world'
enum... -
Object
# to _ enum(method = :each , *args) -> Enumerator (8125.0) -
Enumerator.new(self, method, *args) を返します。
...数です。
//emlist[][ruby]{
str = "xyz"
enum = str.enum_for(:each_byte)
p(a = enum.map{|b| '%02x' % b }) #=> ["78", "79", "7a"]
# protects an array from being modified
a = [1, 2, 3]
p(a.to_enum) #=> #<Enumerator: [1, 2, 3]:each>
//}
//emlist[例(ブロックを指定する場合)][ruby]{
modu......_method__, n) do
# size メソッドが nil でなければ size * n を返す。
sz = size
sz * n if sz
end
end
each do |*val|
n.times { yield *val }
end
end
end
%i[hello world].repeat(2) { |w| puts w }
# => 'hello', 'hello', 'world', 'world'
enum... -
Object
# to _ enum(method = :each , *args) {|*args| . . . } -> Enumerator (8125.0) -
Enumerator.new(self, method, *args) を返します。
...数です。
//emlist[][ruby]{
str = "xyz"
enum = str.enum_for(:each_byte)
p(a = enum.map{|b| '%02x' % b }) #=> ["78", "79", "7a"]
# protects an array from being modified
a = [1, 2, 3]
p(a.to_enum) #=> #<Enumerator: [1, 2, 3]:each>
//}
//emlist[例(ブロックを指定する場合)][ruby]{
modu......_method__, n) do
# size メソッドが nil でなければ size * n を返す。
sz = size
sz * n if sz
end
end
each do |*val|
n.times { yield *val }
end
end
end
%i[hello world].repeat(2) { |w| puts w }
# => 'hello', 'hello', 'world', 'world'
enum... -
Object
# respond _ to?(name , include _ all = false) -> bool (8015.0) -
オブジェクトがメソッド name を持つとき真を返します。
...されたメソッドで NotImplementedError が発生する場合は true を返します。
メソッドが定義されていない場合は、Object#respond_to_missing? を呼
び出してその結果を返します。
@param name Symbol または文字列で指定するメソッド名です。......hello
"Bonjour"
end
end
class D
private
def hello
"Guten Tag"
end
end
list = [F.new,D.new]
list.each{|it| puts it.hello if it.respond_to?(:hello)}
#=> Bonjour
list.each{|it| it.instance_eval("puts hello if it.respond_to?(:hello, true)")}
#=> Bonjour
# Guten Tag
module Template... -
Object
:: DATA -> File (8009.0) -
スクリプトの __END__ プログラムの終り以降をアクセスする File オブジェクト。
...__END__
故人西辞黄鶴楼
烟花三月下揚州
孤帆遠影碧空尽
唯見長江天際流
=== 例2
sum = 0
DATA.each_line do |line|
sum += line.to_i
end
DATA.rewind
p DATA.gets # => "sum = 0¥n"
__END__
17
19
23
2...