るりまサーチ

最速Rubyリファレンスマニュアル検索!
904件ヒット [1-100件を表示] (0.064秒)
トップページ > クエリ:-[x] > クエリ:BLOCK[x] > クエリ:new[x]

別のキーワード

  1. _builtin -
  2. open-uri open
  3. irb/input-method new
  4. irb/input-method gets
  5. matrix -

ライブラリ

モジュール

検索結果

<< 1 2 3 ... > >>

Fiddle::Closure::BlockCaller.new(ret, args, abi=Fiddle::Function::DEFAULT) { ... } -> Fiddle::Closure::BlockCaller (21307.0)

Ruby のブロックを呼び出す Fiddle::Closure オブジェクトを返します。

...ddle::Closure オブジェクトを返します。


args、ret で関数の引数と返り値の型を指定します。
指定は Fiddle::Function.new と同様なので、そちら
を参照してください。

@param ret 返り値の型
@param args 引数の型を表す配列
@param abi 呼出...

Class#new(*args, &block) -> object (18326.0)

自身のインスタンスを生成して返します。 このメソッドの引数はブロック引数も含め Object#initialize に渡されます。

...も含め Object#initialize に渡されます。

new
は Class#allocate でインスタンスを生成し、
Object#initialize で初期化を行います。

@param args Object#initialize に渡される引数を指定します。

@param block Object#initialize に渡されるブロックを指...
...定します。

//emlist[例][ruby]{
# Class クラスのインスタンス、C クラスを生成
C = Class.new # => C

# Class クラスのインスタンス、C クラスのインスタンスを生成
C.new # => #<C:0x00005623f8b4e458>
//}...

Psych::Nodes::Mapping.new(anchor=nil, tag=nil, implicit=true, style=BLOCK) -> Psych::Nodes::Mapping (18308.0)

新たな mapping オブジェクトを生成します。

...上の style を整数で指定します。以下のいずれ
かを指定できます。
* Psych::Nodes::Mapping::ANY
* Psych::Nodes::Mapping::BLOCK
* Psych::Nodes::Mapping::FLOW

@param anchor mapping に付加された anchor
@param tag mapping に付加された tag
@param implicit mapping...

Psych::Nodes::Sequence.new(anchor=nil, tag=nil, implicit=true, style=BLOCK) -> Psych::Nodes::Sequence (18308.0)

新たな sequence オブジェクトを生成します。

...の style を整数で指定します。以下のいずれ
かを指定できます。
* Psych::Nodes::Sequence::ANY
* Psych::Nodes::Sequence::BLOCK
* Psych::Nodes::Sequence::FLOW

@param anchor sequence に付加された anchor
@param tag sequence に付加された tag
@param implicit seque...

Proc.new -> Proc (18256.0)

ブロックをコンテキストとともにオブジェクト化して返します。

...true のときには警告メッセージ
「warning: Capturing the given block using Proc.new is deprecated; use `&block` instead」
が出力され、Ruby 3.0 では
ArgumentError (tried to create Proc object without a block)
が発生します。

ブロックを指定しなければ、このメ...
...ブロックがないのにブロックを省略した呼び出しを行ったときに発生します。

//emlist[例][ruby]{
def foo
pr = Proc.new
pr.call(1)
end
foo {|arg| p arg }
# => 1
//}

これは以下と同じです。

//emlist[例][ruby]{
def foo
yield(1)
end
foo {|arg| p arg }
#...
...umentError が発生します。

//emlist[例][ruby]{
def foo
Proc.new
end
foo
# => -:2:in `new': tried to create Proc object without a block (ArgumentError)
# from -:2:in `foo'
# from -:4:in `<main>'
//}

Proc.new は、Proc#initialize が定義されていれば
オブジェクト...

絞り込み条件を変える

Proc.new { ... } -> Proc (18256.0)

ブロックをコンテキストとともにオブジェクト化して返します。

...true のときには警告メッセージ
「warning: Capturing the given block using Proc.new is deprecated; use `&block` instead」
が出力され、Ruby 3.0 では
ArgumentError (tried to create Proc object without a block)
が発生します。

ブロックを指定しなければ、このメ...
...ブロックがないのにブロックを省略した呼び出しを行ったときに発生します。

//emlist[例][ruby]{
def foo
pr = Proc.new
pr.call(1)
end
foo {|arg| p arg }
# => 1
//}

これは以下と同じです。

//emlist[例][ruby]{
def foo
yield(1)
end
foo {|arg| p arg }
#...
...umentError が発生します。

//emlist[例][ruby]{
def foo
Proc.new
end
foo
# => -:2:in `new': tried to create Proc object without a block (ArgumentError)
# from -:2:in `foo'
# from -:4:in `<main>'
//}

Proc.new は、Proc#initialize が定義されていれば
オブジェクト...
...を行ったときに発生します。

//emlist[][ruby]{
pr = Proc.new {|arg| p arg }
pr.call(1) # => 1
//}

//emlist[][ruby]{
Proc.new # => -e:1:in `new': tried to create Proc object without a block (ArgumentError)
//}

Proc.new は、Proc#initialize が定義されていれば
オブジェクト...

Enumerator::Lazy.new(obj, size=nil) {|yielder, *values| ... } -> Enumerator::Lazy (18225.0)

Lazy Enumerator を作成します。Enumerator::Lazy#force メソッドなどに よって列挙が実行されたとき、objのeachメソッドが実行され、値が一つずつ ブロックに渡されます。ブロックは、yielder を使って最終的に yield される値を 指定できます。

...e#filter_map と、その遅延評価版を定義する例][ruby]{
module Enumerable
def filter_map(&block)
map(&block).compact
end
end

class Enumerator::Lazy
def filter_map
Lazy.new(self) do |yielder, *values|
result = yield *values
yielder << result if result
end
e...
...nd
end

1.step.lazy.filter_map{|i| i*i if i.even?}.first(5)
# => [4, 16, 36, 64, 100]
//}

@raise ArgumentError 引数を指定しなかった場合、ブロックを指定しなかった場合に発生します。

@see Enumerator.new...

Psych::Nodes::Mapping::BLOCK -> Integer (18223.0)

block style を表します。

...block style を表します。

@see Psych::Nodes::Mapping.new,
Psych::Nodes::Mapping#style,
Psych::Handler#start_mapping...

Psych::Nodes::Sequence::BLOCK -> Integer (18223.0)

block style を表します。

...block style を表します。

@see Psych::Nodes::Sequence.new,
Psych::Nodes::Sequence#style,
Psych::Handler#start_sequence...

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

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" を出力します
//}

実装の都合...
...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 Point x=nil, y=2>
Point.new(z: 3) # ArgumentError (unkn...
...{
Point = Struct.new(:x, :y)
Point.new(x: 1, y: 2) # => #<struct Point x={:x=>1, :y=>2}, y=nil>
# warning: 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).

# keywor...
...Point1 = Struct.new(:x, :y)
Point1.new(1, 2) # => #<struct Point1 x=1, y=2>
Point1.new(x: 1, y: 2) # => #<struct Point1 x=1, y=2>
Point1.new(x: 1) # => #<struct Point1 x=1, y=nil>
Point1.new(y: 2) # => #<struct Point1 x=nil, y=2>
Point1.new(x: 1, y: 2, z: 3...
...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=1, y=nil>
Point2.new(y: 2) # => #<struct Point2 x=nil, y=2>
Point2.new(x: 1,...

絞り込み条件を変える

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

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" を出力します
//}

実装の都合...
...Point1 = Struct.new(:x, :y)
Point1.new(1, 2) # => #<struct Point1 x=1, y=2>
Point1.new(x: 1, y: 2) # => #<struct Point1 x=1, y=2>
Point1.new(x: 1) # => #<struct Point1 x=1, y=nil>
Point1.new(y: 2) # => #<struct Point1 x=nil, y=2>
Point1.new(x: 1, y: 2, z: 3...
...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=1, y=nil>
Point2.new(y: 2) # => #<struct Point2 x=nil, y=2>
Point2.new(x: 1,...
<< 1 2 3 ... > >>