6件ヒット
[1-6件を表示]
(0.037秒)
別のキーワード
検索結果
先頭5件
-
ARGF
. class # printf(format , *arg) -> nil (96376.0) -
C 言語の printf と同じように、format に従い引数を 文字列に変換して処理対象のファイルに出力します。
C 言語の printf と同じように、format に従い引数を
文字列に変換して処理対象のファイルに出力します。
c:ARGF#inplace時にのみ使用できます。
また $stdout への代入の影響を受けません。
それ以外は出力先を指定しない形式の Kernel.#printf と同じです。
@param format フォーマット文字列です。
@param arg フォーマットされる引数です。 -
Struct
. new(*args) {|subclass| block } -> Class (25273.0) -
Struct クラスに新しいサブクラスを作って、それを返します。
Struct クラスに新しいサブクラスを作って、それを返します。
サブクラスでは構造体のメンバに対するアクセスメソッドが定義されています。
//emlist[例][ruby]{
dog = Struct.new("Dog", :name, :age)
fred = dog.new("fred", 5)
fred.age = 6
printf "name:%s age:%d", fred.name, fred.age
#=> "name:fred age:6" を出力します
//}
実装の都合により、クラス名の省略は後づけの機能でした。
メンバ名に String を指定できるのは後方互換... -
Struct
. new(*args) -> Class (24673.0) -
Struct クラスに新しいサブクラスを作って、それを返します。
Struct クラスに新しいサブクラスを作って、それを返します。
サブクラスでは構造体のメンバに対するアクセスメソッドが定義されています。
//emlist[例][ruby]{
dog = Struct.new("Dog", :name, :age)
fred = dog.new("fred", 5)
fred.age = 6
printf "name:%s age:%d", fred.name, fred.age
#=> "name:fred age:6" を出力します
//}
実装の都合により、クラス名の省略は後づけの機能でした。
メンバ名に String を指定できるのは後方互換... -
TracePoint
. new(*events) {|obj| . . . } -> TracePoint (24097.0) -
新しい TracePoint オブジェクトを作成して返します。トレースを有効 にするには TracePoint#enable を実行してください。
新しい TracePoint オブジェクトを作成して返します。トレースを有効
にするには TracePoint#enable を実行してください。
//emlist[例:irb で実行した場合][ruby]{
trace = TracePoint.new(:call) do |tp|
p [tp.lineno, tp.defined_class, tp.method_id, tp.event]
end
# => #<TracePoint:0x007f17372cdb20>
trace.enable
# => false
puts "Hello, TracePoint!"
# .... -
Struct
. [](*args) -> Struct (24028.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) -> Struct (24028.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]
//}