別のキーワード
種類
- 文書 (85)
- インスタンスメソッド (11)
- 特異メソッド (11)
ライブラリ
- ビルトイン (22)
クラス
- Module (11)
オブジェクト
- main (11)
キーワード
-
1
. 6 . 8から1 . 8 . 0への変更点(まとめ) (11) -
NEWS for Ruby 2
. 1 . 0 (11) -
NEWS for Ruby 2
. 5 . 0 (7) -
NEWS for Ruby 2
. 7 . 0 (5) -
NEWS for Ruby 3
. 0 . 0 (4) -
NEWS for Ruby 3
. 1 . 0 (3) - Ruby用語集 (11)
-
ruby 1
. 6 feature (11) -
ruby 1
. 8 . 4 feature (11) - クラス/メソッドの定義 (11)
検索結果
先頭5件
-
Module
# include(*mod) -> self (18279.0) -
モジュール mod をインクルードします。
...@raise ArgumentError 継承関係が循環してしまうような include を行った場合に発生します。
//emlist[例][ruby]{
module M
end
module M2
include M
end
module M
include M2
end
//}
実行結果:
-:3:in `append_features': cyclic include detected (ArgumentError)......in `include'
from -:3
インクルードとは、指定されたモジュールの定義
(メソッド、定数) を引き継ぐことです。
インクルードは多重継承の代わりに用いられており、 mix-in とも呼びます。
//emlist[例][ruby]{
class C
include Fi......leTest
include Math
end
p C.ancestors
# => [C, Math, FileTest, Object, Kernel]
//}
モジュールの機能追加は、クラスの継承関係の間にそのモジュールが挿入
されることで実現されています。従って、メソッドの探索などは
スーパークラスよ... -
main
. include(*modules) -> self (18225.0) -
引数 modules で指定したモジュールを後ろから順番に Object にインクルードします。
...odules Module のインスタンス( Enumerable など)を指定します。
@raise ArgumentError 継承関係が循環してしまうような include を行った場
合に発生します。
//emlist[例:][ruby]{
include Math
hypot(3, 4) # => 5.0
//}
@see Module#include... -
NEWS for Ruby 3
. 0 . 0 (1716.0) -
NEWS for Ruby 3.0.0 このドキュメントは前回リリース以降のバグ修正を除くユーザーに影響のある機能の変更のリストです。
...照してください。
== 言語仕様の変更
* Keyword arguments are now separated from positional arguments.
Code that resulted in deprecation warnings in Ruby 2.7 will now
result in ArgumentError or different behavior. 14183
* Procs accepting a single rest argument and keywords......gument and no keywords.
16166
//emlist[][ruby]{
pr = proc{|*a, **kw| [a, kw]}
pr.call([1])
# 2.7 => [[1], {}]
# 3.0 => [[[1]], {}]
pr.call([1, {a: 1}])
# 2.7 => [[1], {:a=>1}] # and deprecation warning
# 3.0 => a=>1}, {}]
//}
* Arguments forwarding (`...`) now supports leading arguments........ 4352
* Kernel#lambda now warns if called without a literal block. 15973
* Kernel.sleep invokes the scheduler hook `#kernel_sleep(...)` in a non-blocking execution context. 16786
* Module
* Module#include and Module#prepend now affect classes and modules that have already included or... -
NEWS for Ruby 2
. 7 . 0 (1542.0) -
NEWS for Ruby 2.7.0 このドキュメントは前回リリース以降のバグ修正を除くユーザーに影響のある機能の変更のリストです。
...== 2.6.0 以降の変更
=== 言語仕様の変更
==== パターンマッチ
* パターンマッチが実験的機能として導入されました。 14912
//emlist[][ruby]{
case [0, [1, 2, 3]]
in [a, [b, *c]]
p a #=> 0
p b #=> 1
p c #=> [2, 3]
end
//}
//emlist[][ruby]{
case {a: 0,......1) #=> {"str"=>1}
//}
* メソッド定義で**nilと書くことで、このメソッドがキーワードを
受け取らないことを明示できるようになりました。このようなメソッドを
キーワード引数付きで呼び出すとArgumentErrorになります。 1......した。 15807
* 変更されたメソッド
* Range#===がString引数に対してもRange#cover?を使うようになりました。
(Ruby 2.6ではString以外の全ての型でRange#include?から変更されていました。)
15449
* RubyVM
* 削除された... -
NEWS for Ruby 2
. 5 . 0 (1404.0) -
NEWS for Ruby 2.5.0 このドキュメントは前回リリース以降のバグ修正を除くユーザーに影響のある機能の変更のリストです。
...ださい。
== 2.4.0 以降の変更
=== 言語仕様の変更
* トップレベルの定数参照を削除しました 11547
* do/end ブロック内部で rescue/else/ensure を書けるようになりました 12906
* 文字列の式展開内部の暗黙の to_s 呼び出しにも refi......952
* Process.last_status を追加。$? と同じです 14043
* Range
* Range.new no longer hides exceptions when comparing begin and
end with #<=> and raise a "bad value for range" ArgumentError
but instead lets the exception from the #<=> call go through.
7688
* Re......html
* https://blog.rubygems.org/2017/10/09/2.6.14-released.html
* https://blog.rubygems.org/2017/08/27/2.6.13-released.html
* securerandom
* SecureRandom.alphanumeric を追加
* set
* Set#to_s を Set#inspect の別名として追加 13676
* Set#=== を Set#include?... -
NEWS for Ruby 3
. 1 . 0 (1302.0) -
NEWS for Ruby 3.1.0 このドキュメントは前回リリース以降のバグ修正を除くユーザーに影響のある機能の変更のリストです。
...参照してください。
== 言語仕様の変更
* ブロックが他のメソッドに渡されるだけの場合は、ブロックの引数を無名にできるようになりました。 11256
//emlist{
def foo(&)
bar(&)
end
//}
* ピン演算子に式を書けるようになりま......メソッド
* Method#public?, Method#private?, Method#protected?, UnboundMethod#public?, UnboundMethod#private?, UnboundMethod#protected? が追加されました。 11689
* Module
* 変更されたメソッド
* Module#prepend はレシーバが既に引数をincludeしている......29
* String#unpack と String#unpack1 が任意のバイト数をスキップした後にアンパックを開始するための offset: キーワード引数を渡せるようになりました。 offset が文字列の範囲外の場合、 ArgumentError 例外が発生します。 18254
* T... -
ruby 1
. 8 . 4 feature (1146.0) -
ruby 1.8.4 feature ruby 1.8.4 での ruby 1.8.3 からの変更点です。
...feature
ruby 1.8.4 での ruby 1.8.3 からの変更点です。
掲載方針
*バグ修正の影響も含めて動作が変わるものを収録する。
*単にバグを直しただけのものは収録しない。
*ライブラリへの単なる定数の追加は収録しない。
以下は......ました。((<ruby-dev:27964>))
module Foo
def initialize
super
end
end
class Bar
include Foo
def initialize
Foo.instance_method(:initialize).bind(self).call
end
end
Bar.new.......4 (2005-12-01) [i686-linux]
# ArgumentError
printf("%2147483648$d\n") # -e:1:in `printf': invalid index - -2147483648$ (ArgumentError)
printf("%2147483649$d\n") # -e:1:in `printf': invalid index - -2147483647$ (ArgumentError)
printf("%4294967296$d\n")... -
NEWS for Ruby 2
. 1 . 0 (1128.0) -
NEWS for Ruby 2.1.0 このドキュメントは前回リリース以降のバグ修正を除くユーザーに影響のある機能の変更のリストです。
...2.0.0 以降の変更
=== 言語仕様の変更
* キーワード引数のデフォルト値が省略可能になりました。これらの「必須キーワード引数」は呼び出し時に明示的に与えなければなりません。
* 整数や小数のリテラルの末尾に'r','......す。
* 拡張: Module#refine はもはや実験的な機能でなくなりました
* 拡張: Module#include と Module#prepend はパブリックメソッドになりました
* Mutex
* Mutex#owned? はもはや実験的な機能ではありません。
* Numeric
* 拡張: N......f.
* Module#define_method Object#define_singleton_method
* 定義したメソッドの名前をシンボルで返すようになりました。メソッドオブジェクトではありません。
* Numeric#quo
* レシーバーが to_r メソッドを持たないとき ArgumentError... -
1
. 6 . 8から1 . 8 . 0への変更点(まとめ) (882.0) -
1.6.8から1.8.0への変更点(まとめ) * ((<1.6.8から1.8.0への変更点(まとめ)/インタプリタの変更>)) * ((<1.6.8から1.8.0への変更点(まとめ)/追加されたクラス/モジュール>)) * ((<1.6.8から1.8.0への変更点(まとめ)/追加されたメソッド>)) * ((<1.6.8から1.8.0への変更点(まとめ)/追加された定数>)) * ((<1.6.8から1.8.0への変更点(まとめ)/拡張されたクラス/メソッド(互換性のある変更)>)) * ((<1.6.8から1.8.0への変更点(まとめ)/変更されたクラス/メソッド(互換性のない変更)>)) * ((<1.6.8から1.8.0への変更点(まとめ)/文法の変更>)) * ((<1.6.8から1.8.0への変更点(まとめ)/正規表現>)) * ((<1.6.8から1.8.0への変更点(まとめ)/Marshal>)) * ((<1.6.8から1.8.0への変更点(まとめ)/Windows 対応>)) * ((<1.6.8から1.8.0への変更点(まとめ)/廃止された(される予定の)機能>)) * ((<1.6.8から1.8.0への変更点(まとめ)/ライブラリ>)) * ((<1.6.8から1.8.0への変更点(まとめ)/拡張ライブラリAPI>)) * ((<1.6.8から1.8.0への変更点(まとめ)/バグ修正>)) * ((<1.6.8から1.8.0への変更点(まとめ)/サポートプラットフォームの追加>))
...の変更点(まとめ)
* ((<1.6.8から1.8.0への変更点(まとめ)/インタプリタの変更>))
* ((<1.6.8から1.8.0への変更点(まとめ)/追加されたクラス/モジュール>))
* ((<1.6.8から1.8.0への変更点(まとめ)/追加されたメソッド>))
* ((<1.6.8から1.8.0......<ruby-dev:20358>))
* Proc.new およびブロック引数で与えられる Proc は
引数チェックがゆるい。break が例外になる。
Proc.new {|a,b,c| p [a,b,c]}.call(1,2)
=> -:1: wrong # of arguments (2 for 3) (ArgumentError)......スタンスになりました。
=== クラス階層
: ((<File::Constants>))
File::Constants は、File クラスでなく IO クラスが include するように
なりました。((<ruby-dev:20964>))
: ((<UnboundMethod>)) [compat]
UnboundMethod クラスは Method クラスのサブク... -
クラス/メソッドの定義 (504.0)
-
クラス/メソッドの定義 * クラス/メソッドの定義: * class * singleton_class * module * method * operator * nest_method * eval_method * singleton_method * class_method * limit * 定義に関する操作: * alias * undef * defined
...ソッドの定義
* クラス/メソッドの定義:
* class
* singleton_class
* module
* method
* operator
* nest_method
* eval_method
* singleton_method
* class_method
* limit
* 定義に関する操作:
* alias
* undef
* defined
===[a:c......い。Net を include できるなどのため)
module Net
class HTTP
end
class FTP
end
end
obj = Net::HTTP.new
# あるいは
include Net
obj = HTTP.new
# 以下のような使い方は組み込みのクラスにも見られる
# 利用者は File::Constants を include することで......ます。
//emlist[例][ruby]{
def foo(x, y = 1) # 2番目の引数yにデフォルト値を指定
10 * x + y
end
p foo(1, 5) #=> 15
p foo(3) #=> 31
p foo #=> ArgumentError (wrong number of arguments)
//}
デフォルト値を指定する引数の位置は、1つの連続した区... -
ruby 1
. 6 feature (186.0) -
ruby 1.6 feature ruby version 1.6 は安定版です。この版での変更はバグ修正がメイン になります。
...$; が有効にな
るのは引数省略時だけでした。
$; = ":"
p "a:b:c".split(nil)
=> -:2:in `split': bad separator (ArgumentError)
from -:2
ruby 1.6.7 (2002-03-01) [i586-linux]
=> ruby 1.6.7 (2002-07-30) [i586-linux]
["a", "b", "c"]
: 2002-06......=> ruby 1.6.7 (2002-07-30) [i586-linux]
"0"
: 2002-05-23 -* オプション(?)
以前まで、
#! ruby -*- mode: ruby -*-
のような Emacs の '-*-' 指定を使用したスクリプトのために -* 以降を無
視する(何もしないオプションとして認識)......18>)), ((<ruby-dev:15684>)),
((<ruby-dev:15757>))
: ((<Module/include>))
モジュールが再帰的に include されないようになりました。
module Foo; end
module Bar; include Foo; end
module Foo; include Bar; end
p Foo.ancestors
=> ruby 1.6.6 (2001-12-26) [i... -
Ruby用語集 (90.0)
-
Ruby用語集 A B C D E F G I J M N O R S Y
...と呼ぶ。
(ここでいうインスタンスは、当該のクラスやその子孫クラス、あるいは当該の
モジュールを include したクラスやその子孫クラスのインスタンスを指す)
特異メソッドは特異クラスから見ればインスタンス......str.size」「user&.name」といったメソッド呼び出しにおける
「.」「&.」も演算子である。
「[*0..9]」におけるいわゆる splat 展開の * や、
Proc オブジェクトをブロックとして渡す「strs.map(&:length)」に
おける & も演算子であ......扱いされない。
ただしパス名には使えず、ヌル文字を含んだ文字列を File.open や
Pathname.new に与えると ArgumentError が発生する。
他の言語では文字列の終端を意味することがあるので、文字列データをやりとり
するう...