Returns an array of flattened objects returned by the block.
With a block given, calls the block with successive elements; returns a flattened array of objects returned by the block:
[0, 1, 2, 3].flat_map {|element| -element } # => [0, -1, -2, -3] [0, 1, 2, 3].flat_map {|element| [element, -element] } # => [0, 0, 1, -1, 2, -2, 3, -3] [[0, 1], [2, 3]].flat_map {|e| e + [100] } # => [0, 1, 100, 2, 3, 100] {foo: 0, bar: 1, baz: 2}.flat_map {|key, value| [key, value] } # => [:foo, 0, :bar, 1, :baz, 2]
With no block given, returns an Enumerator
.
Alias: collect_concat
.
Enters exclusive section and executes the block. Leaves the exclusive section automatically when the block exits. See example under MonitorMixin
.
Returns the source file origin from the given object
.
See ::trace_object_allocations
for more information and examples.
Convert the given options into a serialized options string.
Returns a data represents the current console mode.
You must require ‘io/console’ to use this method.
Returns a new lazy enumerator with the concatenated results of running block
once for every element in the lazy enumerator.
["foo", "bar"].lazy.flat_map {|i| i.each_char.lazy}.force #=> ["f", "o", "o", "b", "a", "r"]
A value x
returned by block
is decomposed if either of the following conditions is true:
x
responds to both each and force, which means that x
is a lazy enumerator.
x
is an array or responds to to_ary.
Otherwise, x
is contained as-is in the return value.
[{a:1}, {b:2}].lazy.flat_map {|i| i}.force #=> [{:a=>1}, {:b=>2}]
Returns the destination encoding as an encoding object.
Returns the destination encoding as an encoding object.
Returns the destination encoding as an Encoding
object.
Create a new PinnedExpressionNode
node
Create a new UntilNode
node
Create a new InstanceVariableAndWriteNode
node
Create a new InstanceVariableOrWriteNode
node
Create a new InstanceVariableReadNode
node
Create a new InstanceVariableTargetNode
node
Create a new InstanceVariableWriteNode
node
Create a new MultiTargetNode
node
Create a new MultiWriteNode
node
Create a new SourceEncodingNode
node