るりまサーチ

最速Rubyリファレンスマニュアル検索!
80件ヒット [1-80件を表示] (0.022秒)

別のキーワード

  1. cgi element_init
  2. cgi/html element_init
  3. irb/ext/save-history init_save_history
  4. rake init
  5. inspector init

ライブラリ

クラス

モジュール

キーワード

検索結果

Struct.[](*args) -> Struct (18107.0)

(このメソッドは Struct の下位クラスにのみ定義されています) 構造体オブジェクトを生成して返します。

(このメソッドは Struct の下位クラスにのみ定義されています)
構造体オブジェクトを生成して返します。

@param args 構造体の初期値を指定します。メンバの初期値は指定されなければ nil です。

@return 構造体クラスのインスタンス。

@raise ArgumentError 構造体のメンバの数よりも多くの引数を指定した場合に発生します。

//emlist[例][ruby]{
Foo = Struct.new(:foo, :bar)
foo = Foo.new(1)
p foo.values # => [1, nil]
//}

Struct.new(*args, keyword_init: nil) -> Class (3132.0)

Struct クラスに新しいサブクラスを作って、それを返します。

...のが無難です。

@param args 構造体を定義するための可変長引数。String または Symbol を指定します。
@param keyword_init true を指定すると、キーワード引数で初期化する構造体を定義します。
Ruby 3.1 では互換性に影...
...待する構造体には明示的に false を指定してください。

//emlist[例][ruby]{
Point = Struct.new(:x, :y, keyword_init: true) # => Point(keyword_init: true)
Point.new(x: 1, y: 2) # => #<struct Point x=1, y=2>
Point.new(x: 1) # => #<struct Point x=1, y=nil>
Point.new(y: 2)...
...Passing only keyword arguments to Struct#initialize will behave differently from Ruby 3.2. Please use a Hash literal like .new({k: v}) instead of .new(k: v).

# keyword_init: falseを指定すると警告は出ない
Point2 = Struct.new(:x, :y, keyword_init: false)
Point2.new(x: 1, y: 2) # => #<st...

Struct.new(*args, keyword_init: nil) {|subclass| block } -> Class (3132.0)

Struct クラスに新しいサブクラスを作って、それを返します。

...のが無難です。

@param args 構造体を定義するための可変長引数。String または Symbol を指定します。
@param keyword_init true を指定すると、キーワード引数で初期化する構造体を定義します。
Ruby 3.1 では互換性に影...
...待する構造体には明示的に false を指定してください。

//emlist[例][ruby]{
Point = Struct.new(:x, :y, keyword_init: true) # => Point(keyword_init: true)
Point.new(x: 1, y: 2) # => #<struct Point x=1, y=2>
Point.new(x: 1) # => #<struct Point x=1, y=nil>
Point.new(y: 2)...
...Passing only keyword arguments to Struct#initialize will behave differently from Ruby 3.2. Please use a Hash literal like .new({k: v}) instead of .new(k: v).

# keyword_init: falseを指定すると警告は出ない
Point2 = Struct.new(:x, :y, keyword_init: false)
Point2.new(x: 1, y: 2) # => #<st...

Struct.new(*args, keyword_init: nil) -> Class (3126.0)

Struct クラスに新しいサブクラスを作って、それを返します。

...のが無難です。

@param args 構造体を定義するための可変長引数。String または Symbol を指定します。
@param keyword_init 構造体クラスのインスタンスを生成する際に、キーワード引数を使用するかどうかを指定します。値の意味は...
...# => #<struct Point1 x=nil, y=2>
Point1.new(x: 1, y: 2, z: 3) # => ArgumentError (unknown keywords: z)

Point2 = Struct.new(:x, :y, keyword_init: nil)
Point2.new(1, 2) # => #<struct Point2 x=1, y=2>
Point2.new(x: 1, y: 2) # => #<struct Point2 x=1, y=2>
Point2.new(x: 1)...
...# => #<struct Point2 x=nil, y=2>
Point2.new(x: 1, y: 2, z: 3) # => ArgumentError (unknown keywords: z)

Point3 = Struct.new(:x, :y, keyword_init: true)
Point3.new(1, 2) # => wrong number of arguments (given 2, expected 0) (ArgumentError)
Point3.new(x: 1, y: 2) # => #<struct...

Struct.new(*args, keyword_init: nil) {|subclass| block } -> Class (3126.0)

Struct クラスに新しいサブクラスを作って、それを返します。

...のが無難です。

@param args 構造体を定義するための可変長引数。String または Symbol を指定します。
@param keyword_init 構造体クラスのインスタンスを生成する際に、キーワード引数を使用するかどうかを指定します。値の意味は...
...# => #<struct Point1 x=nil, y=2>
Point1.new(x: 1, y: 2, z: 3) # => ArgumentError (unknown keywords: z)

Point2 = Struct.new(:x, :y, keyword_init: nil)
Point2.new(1, 2) # => #<struct Point2 x=1, y=2>
Point2.new(x: 1, y: 2) # => #<struct Point2 x=1, y=2>
Point2.new(x: 1)...
...# => #<struct Point2 x=nil, y=2>
Point2.new(x: 1, y: 2, z: 3) # => ArgumentError (unknown keywords: z)

Point3 = Struct.new(:x, :y, keyword_init: true)
Point3.new(1, 2) # => wrong number of arguments (given 2, expected 0) (ArgumentError)
Point3.new(x: 1, y: 2) # => #<struct...

絞り込み条件を変える

Struct.new(*args, keyword_init: false) -> Class (3120.0)

Struct クラスに新しいサブクラスを作って、それを返します。

...または Symbol を指定します。
@param keyword_init true を指定すると、キーワード引数で初期化する構造体を定義します。

//emlist[例][ruby]{
Point = Struct.new(:x, :y, keyword_init: true) # => Point(keyword_init: true)
Point.new(x: 1, y: 2) # => #<struct Point x=1...

Struct.new(*args, keyword_init: false) {|subclass| block } -> Class (3120.0)

Struct クラスに新しいサブクラスを作って、それを返します。

...または Symbol を指定します。
@param keyword_init true を指定すると、キーワード引数で初期化する構造体を定義します。

//emlist[例][ruby]{
Point = Struct.new(:x, :y, keyword_init: true) # => Point(keyword_init: true)
Point.new(x: 1, y: 2) # => #<struct Point x=1...

MiniTest::Mock#expect(name, retval, args = []) -> self (3100.0)

モックを構築するメソッドです。

モックを構築するメソッドです。

@param name メソッド名を指定します。

@param retval 返り値として期待する値を指定します。

@param args 引数として期待する値を配列で指定します。

MiniTest::Unit#process_args(args = []) -> Hash (3100.0)

optparse を使ってコマンドライン引数を解析した結果を返します。

optparse を使ってコマンドライン引数を解析した結果を返します。

@param args コマンドライン引数を指定します。

@see optparse

MiniTest::Unit#run(args = []) -> Fixnum | nil (3100.0)

全てのテストを実行するためのメソッドです。

全てのテストを実行するためのメソッドです。

@param args コマンドライン引数を指定します。

絞り込み条件を変える

Struct.new(*args) -> Class (3012.0)

Struct クラスに新しいサブクラスを作って、それを返します。

...るための可変長引数。String または Symbol を指定します。

//emlist[例][ruby]{
Point = Struct.new(:x, :y, keyword_init: true) # => Point(keyword_init: true)
Point.new(x: 1, y: 2) # => #<struct Point x=1, y=2>
Point.new(x: 1) # => #<struct Point x=1, y=nil>
Point.new(y: 2)...

Struct.new(*args) {|subclass| block } -> Class (3012.0)

Struct クラスに新しいサブクラスを作って、それを返します。

...るための可変長引数。String または Symbol を指定します。

//emlist[例][ruby]{
Point = Struct.new(:x, :y, keyword_init: true) # => Point(keyword_init: true)
Point.new(x: 1, y: 2) # => #<struct Point x=1, y=2>
Point.new(x: 1) # => #<struct Point x=1, y=nil>
Point.new(y: 2)...

Struct.new(*args) -> Struct (3007.0)

(このメソッドは Struct の下位クラスにのみ定義されています) 構造体オブジェクトを生成して返します。

(このメソッドは Struct の下位クラスにのみ定義されています)
構造体オブジェクトを生成して返します。

@param args 構造体の初期値を指定します。メンバの初期値は指定されなければ nil です。

@return 構造体クラスのインスタンス。

@raise ArgumentError 構造体のメンバの数よりも多くの引数を指定した場合に発生します。

//emlist[例][ruby]{
Foo = Struct.new(:foo, :bar)
foo = Foo.new(1)
p foo.values # => [1, nil]
//}

OptionParser#summarize(to = [], width = self.summary_width, max = width - 1, indent= self.summary_indent) -> () (118.0)

サマリを指定された to へと加えていきます。

...s|
opts.on_head("-i", "--init")
opts.on("-u", "--update")
opts.on_tail("-h", "--help")
end

opts.summarize
# => [" -i, --init\n", " -u, --update\n", " -h, --help\n"]
opts.summarize(["description\n"], 10, 8, " ")
# => ["description\n", " -i\n", " --init\n", " -u\n", " --up...

OptionParser#summarize(to = [], width = self.summary_width, max = width - 1, indent= self.summary_indent) {|line| ... } -> () (118.0)

サマリを指定された to へと加えていきます。

...s|
opts.on_head("-i", "--init")
opts.on("-u", "--update")
opts.on_tail("-h", "--help")
end

opts.summarize
# => [" -i, --init\n", " -u, --update\n", " -h, --help\n"]
opts.summarize(["description\n"], 10, 8, " ")
# => ["description\n", " -i\n", " --init\n", " -u\n", " --up...

絞り込み条件を変える

RubyVM::AbstractSyntaxTree.of(proc) -> RubyVM::AbstractSyntaxTree::Node (24.0)

引数 proc に渡したProcやメソッドオブジェクトの抽象構文木を返します。

...ません。

@param proc Procもしくはメソッドオブジェクトを指定します。

//emlist[][ruby]{
pp RubyVM::AbstractSyntaxTree.of(proc {1 + 2})
# => (SCOPE@2:38-2:45
# tbl: []
# args: nil
# body:
# (OPCALL@2:39-2:44 (LIT@2:39-2:40 1) :+
# (LIST@2:43-2:44 (L...
...:AbstractSyntaxTree.of(method(:hello))
# => (SCOPE@5:0-7:3
# tbl: []
# args:
# (ARGS@5:9-5:9
# pre_num: 0
# pre_init: nil
# opt: nil
# first_post: nil
# post_num: 0
# post_init: nil
# rest: nil
# kw: nil
# kwrest: nil
#...
...type が :ERROR であるようなノードに置き換えてツリーを生成します。

//emlist[][ruby]{
pp RubyVM::AbstractSyntaxTree.of(proc {1 + 2})
# => (SCOPE@2:38-2:45
# tbl: []
# args: nil
# body:
# (OPCALL@2:39-2:44 (LIT@2:39-2:40 1) :+
# (LIST@2:43-2:44 (LI...

RubyVM::AbstractSyntaxTree.of(proc, keep_script_lines: false, error_tolerant: false, keep_tokens: false) -> RubyVM::AbstractSyntaxTree::Node (24.0)

引数 proc に渡したProcやメソッドオブジェクトの抽象構文木を返します。

...type が :ERROR であるようなノードに置き換えてツリーを生成します。

//emlist[][ruby]{
pp RubyVM::AbstractSyntaxTree.of(proc {1 + 2})
# => (SCOPE@2:38-2:45
# tbl: []
# args: nil
# body:
# (OPCALL@2:39-2:44 (LIT@2:39-2:40 1) :+
# (LIST@2:43-2:44 (LI...
...:AbstractSyntaxTree.of(method(:hello))
# => (SCOPE@5:0-7:3
# tbl: []
# args:
# (ARGS@5:9-5:9
# pre_num: 0
# pre_init: nil
# opt: nil
# first_post: nil
# post_num: 0
# post_init: nil
# rest: nil
# kw: nil
# kwrest: nil
#...

NEWS for Ruby 3.1.0 (12.0)

NEWS for Ruby 3.1.0 このドキュメントは前回リリース以降のバグ修正を除くユーザーに影響のある機能の変更のリストです。

...mlist[][ruby]{
foo[0] = bar
//}

* 次の評価順序になります。

//emlist{
1. `foo`
2. `bar`
3. `[]=` called on the result of `foo`
//}

* Ruby 3.1.0より前は、多重代入の評価順序が上記のようではありませんでした。このコードでは、

//emlist[][rub...
...`foo`
4. `[]=` called on the result of `foo`
5. `bar`
6. `baz=` called on the result of `bar`
//}

* Ruby 3.1.0から単一代入と評価順序が一致するようになり、左が右より先に評価されます。

//emlist{
1. `foo`
2. `bar`
3. `a`
4. `b`
5. `[]=` called on...
...することができます。 17795

* Struct
* 新規メソッド
* StructClass#keyword_init? が追加されました。 18008
* 変更されたメソッド
* Struct#initialize はキーワード引数のみを渡すと警告されるようになりました。ハッシュ...