174件ヒット
[1-100件を表示]
(0.257秒)
クラス
-
ARGF
. class (29) -
Enumerator
:: Lazy (22) - IO (18)
- Module (11)
- String (58)
- StringIO (36)
キーワード
- chars (50)
-
collect
_ concat (11) -
each
_ grapheme _ cluster (14) -
flat
_ map (11) -
instance
_ method (11)
検索結果
先頭5件
-
String
# each _ char -> Enumerator (21209.0) -
文字列の各文字に対して繰り返します。
...文字列の各文字に対して繰り返します。
たとえば、
//emlist[][ruby]{
"hello世界".each_char {|c| print c, ' ' }
//}
は次のように出力されます。
h e l l o 世 界
@see String#chars... -
StringIO
# each _ char -> Enumerator (21209.0) -
自身に含まれる文字を一文字ずつブロックに渡して評価します。
...自身に含まれる文字を一文字ずつブロックに渡して評価します。
自身は読み込み用にオープンされていなければなりません。
@raise IOError 自身が読み込み用にオープンされていない場合に発生します。
@see IO#each_char... -
String
# each _ char {|cstr| block } -> self (21109.0) -
文字列の各文字に対して繰り返します。
...文字列の各文字に対して繰り返します。
たとえば、
//emlist[][ruby]{
"hello世界".each_char {|c| print c, ' ' }
//}
は次のように出力されます。
h e l l o 世 界
@see String#chars... -
StringIO
# each _ char {|c| . . . } -> self (21109.0) -
自身に含まれる文字を一文字ずつブロックに渡して評価します。
...自身に含まれる文字を一文字ずつブロックに渡して評価します。
自身は読み込み用にオープンされていなければなりません。
@raise IOError 自身が読み込み用にオープンされていない場合に発生します。
@see IO#each_char... -
ARGF
. class # each _ char -> Enumerator (18263.0) -
レシーバに含まれる文字を一文字ずつブロックに渡して評価します。
...ename を使用します。
ブロックが与えられなかった場合は、Enumerator オブジェクトを生成し
て返します。
例:
# $ echo "line1\n" > test1.txt
# $ echo "line2\n" > test2.txt
# $ ruby test.rb test1.txt test2.txt
# test.rb
ARGF.each_char # => #<En......umerator: ARGF:each_char>
ARGF.each_char{|e|p e}
# => "l"
# "i"
# "n"
# "e"
# "1"
# "\n"
# "l"
# "i"
# "n"
# "e"
# "2"
# "\n"
@see IO#each_char... -
IO
# each _ char -> Enumerator (18209.0) -
self に含まれる文字を一文字ずつブロックに渡して評価します。
...ません。
ブロックを省略した場合は各文字について繰り返す Enumerator を返します。
@raise IOError self が読み込み用にオープンされていない場合に発生します。
f = File.new("testfile")
f.each_char {|c| print c, ' ' } #=> #<File:testfile>... -
StringIO
# each _ char -> Enumerator (18209.0) -
自身に含まれる文字を一文字ずつブロックに渡して評価します。
...自身に含まれる文字を一文字ずつブロックに渡して評価します。
自身は読み込み用にオープンされていなければなりません。
@raise IOError 自身が読み込み用にオープンされていない場合に発生します。
@see IO#each_char... -
ARGF
. class # each _ char { |c| . . . } -> self (18163.0) -
レシーバに含まれる文字を一文字ずつブロックに渡して評価します。
...ename を使用します。
ブロックが与えられなかった場合は、Enumerator オブジェクトを生成し
て返します。
例:
# $ echo "line1\n" > test1.txt
# $ echo "line2\n" > test2.txt
# $ ruby test.rb test1.txt test2.txt
# test.rb
ARGF.each_char # => #<En......umerator: ARGF:each_char>
ARGF.each_char{|e|p e}
# => "l"
# "i"
# "n"
# "e"
# "1"
# "\n"
# "l"
# "i"
# "n"
# "e"
# "2"
# "\n"
@see IO#each_char... -
StringIO
# each _ char {|c| . . . } -> self (18109.0) -
自身に含まれる文字を一文字ずつブロックに渡して評価します。
...自身に含まれる文字を一文字ずつブロックに渡して評価します。
自身は読み込み用にオープンされていなければなりません。
@raise IOError 自身が読み込み用にオープンされていない場合に発生します。
@see IO#each_char... -
Module
# instance _ method(name) -> UnboundMethod (6113.0) -
self のインスタンスメソッド name をオブジェクト化した UnboundMethod を返します。
...スメソッド name をオブジェクト化した UnboundMethod を返します。
@param name メソッド名を Symbol または String で指定します。
@raise NameError self に存在しないメソッドを指定した場合に発生します。
@see Module#public_instance_method, Obje......class Interpreter
def do_a() print "there, "; end
def do_d() print "Hello "; end
def do_e() print "!\n"; end
def do_v() print "Dave"; end
Dispatcher = {
"a" => instance_method(:do_a),
"d" => instance_method(:do_d),
"e" => instance_method(:do_e),
"v" => instance_meth......od(: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!
//}... -
Enumerator
:: Lazy # collect _ concat {|item| . . . } -> Enumerator :: Lazy (6107.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 は、......force メソッドを持つ (例:Enumerator::Lazy) とき
それ以外のときは、x は分解されず、そのままの値として使われます。
//emlist[][ruby]{
[{a:1}, {b:2}].lazy.flat_map {|i| i}.force
#=> [{:a=>1}, {:b=>2}]
//}
@raise ArgumentError ブロックを指定しなか......った場合に発生します。
@see Enumerable#flat_map... -
String
# chars -> [String] (3129.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 までは de......precated の警告が出ますが、Ruby 2.7 で警告は削除されました。
@see String#each_char...