るりまサーチ

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

別のキーワード

  1. _builtin puts
  2. stringio puts
  3. csv puts
  4. kernel puts
  5. openssl puts

検索結果

クラス/メソッドの定義 (115.0)

クラス/メソッドの定義 * クラス/メソッドの定義: * class * singleton_class * module * method * operator * nest_method * eval_method * singleton_method * class_method * limit * 定義に関する操作: * alias * undef * defined

...結果
として他の言語における「関数」のように使えます。

//emlist[例][ruby]{
def hello # 引数のないメソッド。
puts
"Hello, world!"
end

def foo(a, b) # 引数のあるメソッド。括弧を省いてdef foo a, bとも
a + 3 * b
end
//}

メソッド名...
...t[例][ruby]{
def foo(x, *xs)
puts
"#{x} : #{xs.inspect}" # Object#inspect は p のような詳細な内部表示
end
foo(1) #=> 1 : []
foo(1, 2) #=> 1 : [2]
foo(1, 2, 3) #=> 1 : [2, 3]

def bar(x, *) # 残りの引数を単に無視したいとき
puts
"#{x}"
end
bar(1) #=...
...タを定義する方法の一つです。イテレータを定義する代表的な方法は
yield を呼び出すことです。
他に Proc.new/Kernel.#proc を使う方法などもあります。
ブロックが与えられなかった場合のブロック引数の値はnilです。

//emlist[...

NEWS for Ruby 3.0.0 (79.0)

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

...ds (e.g. IO#puts, IO#gets) may invoke the scheduler hook `#io_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...
...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...