33件ヒット
[1-33件を表示]
(0.038秒)
種類
- 文書 (22)
- インスタンスメソッド (11)
ライブラリ
- ビルトイン (11)
クラス
- Module (11)
キーワード
-
NEWS for Ruby 2
. 5 . 0 (7) -
NEWS for Ruby 3
. 0 . 0 (4) - クラス/メソッドの定義 (11)
検索結果
先頭5件
-
Module
# alias _ method(new , original) -> Symbol (18131.0) -
メソッドの別名を定義します。
...メソッドの別名を定義します。
//emlist[例][ruby]{
module Kernel
alias_method :hoge, :puts # => :hoge
alias_method "foo", :puts # => :foo
end
//}
alias との違いは以下の通りです。
* メソッド名は String または Symbol で指定します
* グローバル......ます。
@param original 元のメソッド名。String または Symbol で指定します。
@return 作成したエイリアスのメソッド名を表す Symbol を返します。
@see d:spec/def#alias
//emlist[例][ruby]{
module Kernel
alias_method :foo, :puts
end
foo "bar" # bar
//}... -
Module
# alias _ method(new , original) -> self (18131.0) -
メソッドの別名を定義します。
...メソッドの別名を定義します。
//emlist[例][ruby]{
module Kernel
alias_method :hoge, :puts # => Kernel
end
//}
alias との違いは以下の通りです。
* メソッド名は String または Symbol で指定します
* グローバル変数の別名をつけることはで......いメソッド名。String または Symbol で指定します。
@param original 元のメソッド名。String または Symbol で指定します。
@return self を返します。
@see d:spec/def#alias
//emlist[例][ruby]{
module Kernel
alias_method :foo, :puts
end
foo "bar" # bar
//}... -
NEWS for Ruby 3
. 0 . 0 (72.0) -
NEWS for Ruby 3.0.0 このドキュメントは前回リリース以降のバグ修正を除くユーザーに影響のある機能の変更のリストです。
...wait(io, events, timeout)` in a non-blocking execution context. 16786
* Kernel
* Kernel#clone when called with the `freeze: false` keyword will call `#initialize_clone` with the `freeze: false` keyword. 14266
* Kernel#clone when called with the `freeze: true` keyword will call `#initialize......s unfrozen. 16175
* Kernel#eval when called with two arguments will use `"(eval)"` for `__FILE__` and `1` for `__LINE__` in the evaluated code. 4352
* Kernel#lambda now warns if called without a literal block. 15973
* Kernel.sleep invokes the scheduler hook `#kernel_sleep(...)` in a non-......defined method names as symbols. 17314
* Module#alias_method now returns the defined alias as a symbol. 17314
//emlist[][ruby]{
class C; end
module M1; end
module M2; end
C.include M1
M1.include M2
p C.ancestors #=> [C, M1, M2, Object, Kernel, BasicObject]
//}
* Mutex
* `Mutex` is now a... -
NEWS for Ruby 2
. 5 . 0 (42.0) -
NEWS for Ruby 2.5.0 このドキュメントは前回リリース以降のバグ修正を除くユーザーに影響のある機能の変更のリストです。
...r#anybits?, Integer#nobits? を追加 12753
* Integer.sqrt を追加 13219
* Kernel
* Object#yield_self を追加 6721
* Kernel.#pp をrequireなしで使えるようにしました 14123
* Kernel.#warn :uplevel というキーワード引数を追加しました 12882
* Met......attr_accessor, Module#attr_reader, Module#attr_writer はパブリックメソッドになりました 14132
* Module#define_method, Module#alias_method, Module#undef_method, Module#remove_method はパブリックメソッドになりました 14133
* Numeric
* Numeric#step は > で0と......がマルチユーザーセーフである場合のみ。12921
* open-uri
* URI.open を open-uri の Kernel.open の別名として追加しました。
将来 open-uri の Kernel.open は非推奨になります。
* openssl
* Ruby/OpenSSLのバージョンを2.0から2.1に更... -
クラス/メソッドの定義 (18.0)
-
クラス/メソッドの定義 * クラス/メソッドの定義: * class * singleton_class * module * method * operator * nest_method * eval_method * singleton_method * class_method * limit * 定義に関する操作: * alias * undef * defined
...タを定義する方法の一つです。イテレータを定義する代表的な方法は
yield を呼び出すことです。
他に Proc.new/Kernel.#proc を使う方法などもあります。
ブロックが与えられなかった場合のブロック引数の値はnilです。
//emlist[......出し等の一切の評価は行われません。
メソッドの定義内で別名を付けるにはModuleクラスのメソッド
Module#alias_method を利用して下さい。
別名を付けられたメソッドは、その時点でのメソッド定義を引き継
ぎ、元のメソッド......して以下があります。
//emlist[][ruby]{
defined? yield
//}
yield の呼び出しが可能なら真(文字列 "yield")を返します。
Kernel.#block_given? と同様にメソッドがブロック付きで呼ばれたか
を判断する方法になります。
//emlist[][ruby]{
defined?...