62件ヒット
[1-62件を表示]
(0.288秒)
ライブラリ
- ビルトイン (62)
クラス
-
Enumerator
:: Lazy (22) - Module (11)
- String (29)
キーワード
- chars (11)
-
collect
_ concat (11) -
each
_ grapheme _ cluster (7) -
flat
_ map (11) -
instance
_ method (11)
検索結果
先頭5件
-
String
# each _ char {|cstr| block } -> self (26208.0) -
文字列の各文字に対して繰り返します。
...文字列の各文字に対して繰り返します。
たとえば、
//emlist[][ruby]{
"hello世界".each_char {|c| print c, ' ' }
//}
は次のように出力されます。
h e l l o 世 界
@see String#chars... -
String
# chars {|cstr| block } -> self (8128.0) -
文字列の各文字を文字列の配列で返します。(self.each_char.to_a と同じです)
...。(self.each_char.to_a と同じです)
//emlist[例][ruby]{
"hello世界".chars # => ["h", "e", "l", "l", "o", "世", "界"]
//}
ブロックが指定された場合は String#each_char と同じように動作します。
Ruby 2.6 までは deprecated の警告が出ますが、Ruby 2.7 で警......告は削除されました。
@see String#each_char... -
Module
# instance _ method(name) -> UnboundMethod (8118.0) -
self のインスタンスメソッド name をオブジェクト化した UnboundMethod を返します。
...化した UnboundMethod を返します。
@param name メソッド名を Symbol または String で指定します。
@raise NameError self に存在しないメソッドを指定した場合に発生します。
@see Module#public_instance_method, Object#method
//emlist[例][ruby]{
class Inte......d(:do_a),
"d" => instance_method(:do_d),
"e" => instance_method(:do_e),
"v" => instance_method(:do_v)
}
def interpret(string)
string.each_char {|b| Dispatcher[b].bind(self).call }
end
end
interpreter = Interpreter.new
interpreter.interpret('dave')
# => Hello there, Dave!
//}... -
String
# each _ grapheme _ cluster {|grapheme _ cluster| block } -> self (8112.0) -
文字列の書記素クラスタに対して繰り返します。
...スタに対して繰り返します。
String#each_char と違って、
Unicode Standard Annex #29 (https://unicode.org/reports/tr29/)
で定義された書記素クラスタに対して繰り返します。
//emlist[例][ruby]{
"a\u0300".each_char.to_a.size # => 2
"a\u0300".each_grapheme_cluster... -
Enumerator
:: Lazy # collect _ concat {|item| . . . } -> Enumerator :: Lazy (8024.0) -
ブロックの実行結果をひとつに繋げたものに対してイテレートするような Enumerator::Lazy のインスタンスを返します。
...してイテレートするような
Enumerator::Lazy のインスタンスを返します。
//emlist[][ruby]{
["foo", "bar"].lazy.flat_map {|i| i.each_char.lazy}.force
#=> ["f", "o", "o", "b", "a", "r"]
//}
ブロックの返した値 x は、以下の場合にのみ分解され、連結され......それ以外のときは、x は分解されず、そのままの値として使われます。
//emlist[][ruby]{
[{a:1}, {b:2}].lazy.flat_map {|i| i}.force
#=> [{:a=>1}, {:b=>2}]
//}
@raise ArgumentError ブロックを指定しなかった場合に発生します。
@see Enumerable#flat_map... -
Enumerator
:: Lazy # flat _ map {|item| . . . } -> Enumerator :: Lazy (8024.0) -
ブロックの実行結果をひとつに繋げたものに対してイテレートするような Enumerator::Lazy のインスタンスを返します。
...してイテレートするような
Enumerator::Lazy のインスタンスを返します。
//emlist[][ruby]{
["foo", "bar"].lazy.flat_map {|i| i.each_char.lazy}.force
#=> ["f", "o", "o", "b", "a", "r"]
//}
ブロックの返した値 x は、以下の場合にのみ分解され、連結され......それ以外のときは、x は分解されず、そのままの値として使われます。
//emlist[][ruby]{
[{a:1}, {b:2}].lazy.flat_map {|i| i}.force
#=> [{:a=>1}, {:b=>2}]
//}
@raise ArgumentError ブロックを指定しなかった場合に発生します。
@see Enumerable#flat_map...