るりまサーチ (Ruby 3.2)

最速Rubyリファレンスマニュアル検索!
2件ヒット [1-2件を表示] (0.032秒)
トップページ > クエリ:b[x] > クエリ:printf[x] > バージョン:3.2[x] > 種類:特異メソッド[x]

別のキーワード

  1. string b
  2. _builtin b
  3. b string
  4. b _builtin
  5. b

ライブラリ

クラス

検索結果

TracePoint.new(*events) {|obj| ... } -> TracePoint (358.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.new(*args, keyword_init: nil) {|subclass| block } -> Class (322.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 を指定できるのは後方互換...