873件ヒット
[801-873件を表示]
(0.083秒)
別のキーワード
クラス
- Array (96)
-
Enumerator
:: Lazy (124) - Exception (12)
- Hash (10)
- Matrix (100)
- Object (48)
-
Rake
:: FileList (12) -
Thread
:: Backtrace :: Location (48) - Vector (148)
-
WIN32OLE
_ TYPE (12)
モジュール
- Enumerable (240)
- TSort (23)
キーワード
- == (12)
-
absolute
_ path (12) -
base
_ label (12) -
chunk
_ while (12) - collect (108)
- collect! (52)
- collect2 (24)
-
collect
_ concat (36) -
default
_ event _ sources (12) - each (24)
-
each
_ strongly _ connected _ component _ from (23) -
elements
_ to _ f (12) -
elements
_ to _ i (12) -
elements
_ to _ r (12) -
enum
_ for (48) -
filter
_ map (18) -
flat
_ map (36) - grep (12)
-
grep
_ v (10) - inspect (12)
- lazy (12)
- map! (52)
- map2 (12)
- pathmap (12)
-
slice
_ after (24) -
slice
_ before (24) -
slice
_ when (12) -
sort
_ by (24) - sum (24)
-
to
_ enum (48) -
to
_ proc (10) -
to
_ s (12)
検索結果
先頭5件
-
Matrix
# collect!(which = :all) {|element| . . . } -> self (3027.0) -
行列の各要素に対してブロックの適用を繰り返した結果で要素を置き換えます。
...の適用を繰り返した結果で要素を置き換えます。
ブロックのない場合は、自身と map! から生成した Enumerator オブジェクトを返します。
@param which which に以下の Symbol を指定することで、
引数として使われる要素......詳細は、 Matrix#each の項目を参照して下さい。
//emlist[例][ruby]{
require 'matrix'
m = Matrix[[1, 2], [3, 4]]
p m.map! { |element| element * 10 } #=> Matrix[[10, 20], [30, 40]]
p m #=> Matrix[[10, 20], [30, 40]]
//}
@see Matrix#each, Matrix#map... -
Array
# collect {|item| . . . } -> [object] (3021.0) -
各要素に対してブロックを評価した結果を全て含む配列を返します。
...要素に対してブロックを評価した結果を全て含む配列を返します。
ブロックを省略した場合は Enumerator を返します。
//emlist[例][ruby]{
# すべて 3 倍にする
p [1, 2, 3].map {|n| n * 3 } # => [3, 6, 9]
//}
@see Enumerable#collect, Enumerable#map......してブロックを評価した結果を全て含む配列を返します。
ブロックを省略した場合は Enumerator を返します。
//emlist[例][ruby]{
# すべて 3 倍にする
p [1, 2, 3].map {|n| n * 3 } # => [3, 6, 9]
//}
@see Hash#to_h, Enumerable#collect, Enumerable#map... -
Enumerable
# collect {|item| . . . } -> [object] (3021.0) -
各要素に対してブロックを評価した結果を全て含む配列を返します。
...全て含む配列を返します。
ブロックを省略した場合は Enumerator を返します。
//emlist[例][ruby]{
# すべて 3 倍にした配列を返す
p (1..3).map {|n| n * 3 } # => [3, 6, 9]
p (1..3).collect { "cat" } # => ["cat", "cat", "cat"]
//}
@see Array#collect, Array#map......配列を返します。
ブロックを省略した場合は Enumerator を返します。
//emlist[例][ruby]{
# すべて 3 倍にした配列を返す
p (1..3).map {|n| n * 3 } # => [3, 6, 9]
p (1..3).collect { "cat" } # => ["cat", "cat", "cat"]
//}
@see Hash#to_h, Array#collect, Array#map... -
Vector
# collect! {|element| . . . } -> self (3021.0) -
ベクトルの各要素を順番にブロックに渡して評価し、その結果で要素を置き換えます。
...素を置き換えます。
ブロックのない場合は、自身と map! から生成した Enumerator オブジェクトを返します。
//emlist[例][ruby]{
require 'matrix'
v = Vector[1, 2, 3]
p v.map!{ |el| el * 2 } #=> Vector[2, 4, 6]
p v #=> Vector[2, 4, 6]
//}... -
Enumerable
# sum(init=0) -> object (3019.0) -
要素の合計を返します。
...、initを返します。
//emlist[例][ruby]{
{ 1 => 10, 2 => 20 }.sum {|k, v| k * v } # => 50
(1..10).sum # => 55
(1..10).sum {|v| v * 2 } # => 110
('a'..'z').sum # => TypeError
//}
init 引数を明示的に指名する......えます。
//emlist[例][ruby]{
{ 1 => 10, 2 => 20 }.sum([]) #=> [1, 10, 2, 20]
"a\nb\nc".each_line.lazy.map(&:chomp).sum("") #=> "abc"
[[1], [[2]], [3]].sum([]) #=> [1, [2], 3]
//}
"+" メソッドが再定義されている場合、Enumerable#sum は再定義を無......視することがあります(例えばInteger#+)。
@see Array#sum... -
Matrix
# each(which = :all) {|e| . . . } -> self (3013.0) -
行列の各要素を引数としてブロックを呼び出します。
...:lower 対角成分とそれより下側の部分
* :upper対角成分とそれより上側の部分
* :strict_lower 対角成分の下側
* :strict_upper 対角成分の上側
ブロックを省略した場合、 Enumerator を返します。
//emlist[例][ruby]{
require 'matrix'
Matrix[ [......1,2], [3,4] ].each { |e| puts e }
# => prints the numbers 1 to 4
Matrix[ [1,2], [3,4] ].each(:strict_lower).to_a # => [3]
//}
@param which どの要素に対してブロックを呼び出すのかを Symbol で指定します
@see Matrix#each_with_index, Matrix#map... -
Exception
# ==(other) -> bool (125.0) -
自身と指定された other のクラスが同じであり、 message と backtrace が == メソッドで比較して 等しい場合に true を返します。そうでない場合に false を返します。
...自身と指定された other のクラスが同じであり、
message と backtrace が == メソッドで比較して
等しい場合に true を返します。そうでない場合に false を返します。
@param other 自身と比較したいオブジェクトを指定します。......[ruby]{
require "date"
def check_long_month(month)
return if Date.new(2000, month, -1).day == 31
raise "#{month} is not long month"
end
def get_exception
return begin
yield
rescue => e
e
end
end
results = [2, 2, 4].map { |e | get_exception { check_long_month(e) } }
p results.map......e.class }
# => [RuntimeError, RuntimeError, RuntimeError]
p results.map { |e| e.message }
# => ["2 is not long month", "2 is not long month", "4 is not long month"]
# class, message, backtrace が同一のため true になる
p results[0] == results[1] # => true
# class, backtrace が同一だ...