るりまサーチ

最速Rubyリファレンスマニュアル検索!
72件ヒット [1-72件を表示] (0.056秒)
トップページ > クエリ:p[x] > クエリ:__method__[x]

別のキーワード

  1. weakref __setobj__
  2. weakref __getobj__
  3. delegate __setobj__
  4. _builtin __send__
  5. delegate __getobj__

ライブラリ

クラス

モジュール

キーワード

検索結果

Kernel.#__method__ -> Symbol | nil (18125.0)

現在のメソッド名を返します。 メソッドの外で呼ばれると nil を返します。

...名を返します。
メソッドの外で呼ばれると nil を返します。

//emlist[例][ruby]{
def foo
p
__method__
end
alias :bar :foo
foo #=> :foo
bar #=> :foo
p
__method__ #=> nil
//}

現在のメソッド名が alias されたメソッドの場合でも alias 元のメソッド名...

ruby 1.9 feature (174.0)

ruby 1.9 feature ruby version 1.9.0 は開発版です。 以下にあげる機能は将来削除されたり互換性のない仕様変更がなされるかもしれません。 1.9.1 以降は安定版です。 バグ修正がメインになります。

...[api]: 拡張ライブラリ API
* [lib]: ライブラリ
* [parser]: 文法の変更
* [regexp]: 正規表現の機能拡張
* [marshal]: Marshal ファイルのフォーマット変更
* レベル
* [bug]: バグ修正
* [new]: 追加されたクラス/メソッドなど
* [compat...
.../メソッドなど(互換性のある変更) (only backward-compatibility) (影響の範囲が小さいと思われる変更もこちら)
* [change]: 変更されたクラス/メソッドなど(互換性のない変更)
* [experimental]: 変更の中でも特に実験的なもの(将来再...
...:197512>))

=== 2006-06-13

: IPsocket
: TCPsocket
: SOCKSsocket
: TCPserver
: UDPsocket
: UNIXsocket
: UNIXserver

削除

=== 2006-06-11

: __callee__ [new]
: __method__ [new]

((<URL:http://www.dm4lab.to/~usa/ruby/d/200606a.html#id20060610_P1_7>))

: Symbol#to_proc

=== 2006-06-10

* 新機...

Object#enum_for(method = :each, *args) -> Enumerator (18.0)

Enumerator.new(self, method, *args) を返します。

...数 args です。


@param method メソッド名の文字列かシンボルです。
@param 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...
...3]
p
(a.to_enum) #=> #<Enumerator: [1, 2, 3]:each>
//}

//emlist[例(ブロックを指定する場合)][ruby]{
module Enumerable
def repeat(n)
raise ArgumentError, "#{n} is negative!" if n < 0
unless block_given?
# __method__ はここでは :repeat
return to_enum(__method__,...
...end
each do |*val|
n.times { yield *val }
end
end
end

%i[hello world].repeat(2) { |w| puts w }
# => 'hello', 'hello', 'world', 'world'
enum = (1..14).repeat(3)
# => #<Enumerator: 1..14:repeat(3)>
enum.first(4) # => [1, 1, 1, 2]
enum.size # => 42
//}

@see Enumerator, Enumerator#s...

Object#enum_for(method = :each, *args) {|*args| ... } -> Enumerator (18.0)

Enumerator.new(self, method, *args) を返します。

...数 args です。


@param method メソッド名の文字列かシンボルです。
@param 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...
...3]
p
(a.to_enum) #=> #<Enumerator: [1, 2, 3]:each>
//}

//emlist[例(ブロックを指定する場合)][ruby]{
module Enumerable
def repeat(n)
raise ArgumentError, "#{n} is negative!" if n < 0
unless block_given?
# __method__ はここでは :repeat
return to_enum(__method__,...
...end
each do |*val|
n.times { yield *val }
end
end
end

%i[hello world].repeat(2) { |w| puts w }
# => 'hello', 'hello', 'world', 'world'
enum = (1..14).repeat(3)
# => #<Enumerator: 1..14:repeat(3)>
enum.first(4) # => [1, 1, 1, 2]
enum.size # => 42
//}

@see Enumerator, Enumerator#s...

Object#to_enum(method = :each, *args) -> Enumerator (18.0)

Enumerator.new(self, method, *args) を返します。

...数 args です。


@param method メソッド名の文字列かシンボルです。
@param 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...
...3]
p
(a.to_enum) #=> #<Enumerator: [1, 2, 3]:each>
//}

//emlist[例(ブロックを指定する場合)][ruby]{
module Enumerable
def repeat(n)
raise ArgumentError, "#{n} is negative!" if n < 0
unless block_given?
# __method__ はここでは :repeat
return to_enum(__method__,...
...end
each do |*val|
n.times { yield *val }
end
end
end

%i[hello world].repeat(2) { |w| puts w }
# => 'hello', 'hello', 'world', 'world'
enum = (1..14).repeat(3)
# => #<Enumerator: 1..14:repeat(3)>
enum.first(4) # => [1, 1, 1, 2]
enum.size # => 42
//}

@see Enumerator, Enumerator#s...

絞り込み条件を変える

Object#to_enum(method = :each, *args) {|*args| ... } -> Enumerator (18.0)

Enumerator.new(self, method, *args) を返します。

...数 args です。


@param method メソッド名の文字列かシンボルです。
@param 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...
...3]
p
(a.to_enum) #=> #<Enumerator: [1, 2, 3]:each>
//}

//emlist[例(ブロックを指定する場合)][ruby]{
module Enumerable
def repeat(n)
raise ArgumentError, "#{n} is negative!" if n < 0
unless block_given?
# __method__ はここでは :repeat
return to_enum(__method__,...
...end
each do |*val|
n.times { yield *val }
end
end
end

%i[hello world].repeat(2) { |w| puts w }
# => 'hello', 'hello', 'world', 'world'
enum = (1..14).repeat(3)
# => #<Enumerator: 1..14:repeat(3)>
enum.first(4) # => [1, 1, 1, 2]
enum.size # => 42
//}

@see Enumerator, Enumerator#s...