Results for: "tally"

Compile a InstanceVariableTargetNode node

Compile a LocalVariableTargetNode node

Dispatch enter and leave events for AliasGlobalVariableNode nodes and continue walking the tree.

Dispatch enter and leave events for CallAndWriteNode nodes and continue walking the tree.

Dispatch enter and leave events for CallOperatorWriteNode nodes and continue walking the tree.

Dispatch enter and leave events for CallOrWriteNode nodes and continue walking the tree.

Dispatch enter and leave events for ConstantPathTargetNode nodes and continue walking the tree.

Dispatch enter and leave events for GlobalVariableTargetNode nodes and continue walking the tree.

Dispatch enter and leave events for InstanceVariableTargetNode nodes and continue walking the tree.

Dispatch enter and leave events for LocalVariableTargetNode nodes and continue walking the tree.

Copy a AliasGlobalVariableNode node

Copy a CallAndWriteNode node

Copy a CallOperatorWriteNode node

Copy a CallOrWriteNode node

Copy a ConstantPathTargetNode node

Copy a GlobalVariableTargetNode node

Copy a InstanceVariableTargetNode node

Copy a LocalVariableTargetNode node

No documentation available

Replaces the content of self with the content of other_array; returns self:

a = [:foo, 'bar', 2]
a.replace(['foo', :bar, 3]) # => ["foo", :bar, 3]

Returns a new Array whose elements are the elements of self at the given Integer or Range indexes.

For each positive index, returns the element at offset index:

a = [:foo, 'bar', 2]
a.values_at(0, 2) # => [:foo, 2]
a.values_at(0..1) # => [:foo, "bar"]

The given indexes may be in any order, and may repeat:

a = [:foo, 'bar', 2]
a.values_at(2, 0, 1, 0, 2) # => [2, :foo, "bar", :foo, 2]
a.values_at(1, 0..2) # => ["bar", :foo, "bar", 2]

Assigns nil for an index that is too large:

a = [:foo, 'bar', 2]
a.values_at(0, 3, 1, 3) # => [:foo, nil, "bar", nil]

Returns a new empty Array if no arguments given.

For each negative index, counts backward from the end of the array:

a = [:foo, 'bar', 2]
a.values_at(-1, -3) # => [2, :foo]

Assigns nil for an index that is too small:

a = [:foo, 'bar', 2]
a.values_at(0, -5, 1, -6, 2) # => [:foo, nil, "bar", nil, 2]

The given indexes may have a mixture of signs:

a = [:foo, 'bar', 2]
a.values_at(0, -2, 1, -1) # => [:foo, "bar", "bar", 2]

Calls the block with each repeated permutation of length n of the elements of self; each permutation is an Array; returns self. The order of the permutations is indeterminate.

When a block and a positive Integer argument n are given, calls the block with each n-tuple repeated permutation of the elements of self. The number of permutations is self.size**n.

n = 1:

a = [0, 1, 2]
a.repeated_permutation(1) {|permutation| p permutation }

Output:

[0]
[1]
[2]

n = 2:

a.repeated_permutation(2) {|permutation| p permutation }

Output:

[0, 0]
[0, 1]
[0, 2]
[1, 0]
[1, 1]
[1, 2]
[2, 0]
[2, 1]
[2, 2]

If n is zero, calls the block once with an empty Array.

If n is negative, does not call the block:

a.repeated_permutation(-1) {|permutation| fail 'Cannot happen' }

Returns a new Enumerator if no block given:

a = [0, 1, 2]
a.repeated_permutation(2) # => #<Enumerator: [0, 1, 2]:permutation(2)>

Using Enumerators, it’s convenient to show the permutations and counts for some values of n:

e = a.repeated_permutation(0)
e.size # => 1
e.to_a # => [[]]
e = a.repeated_permutation(1)
e.size # => 3
e.to_a # => [[0], [1], [2]]
e = a.repeated_permutation(2)
e.size # => 9
e.to_a # => [[0, 0], [0, 1], [0, 2], [1, 0], [1, 1], [1, 2], [2, 0], [2, 1], [2, 2]]

Returns a new Array containing zero or more leading elements of self; does not modify self.

With a block given, calls the block with each successive element of self; stops if the block returns false or nil; returns a new Array containing those elements for which the block returned a truthy value:

a = [0, 1, 2, 3, 4, 5]
a.take_while {|element| element < 3 } # => [0, 1, 2]
a.take_while {|element| true } # => [0, 1, 2, 3, 4, 5]
a # => [0, 1, 2, 3, 4, 5]

With no block given, returns a new Enumerator:

[0, 1].take_while # => #<Enumerator: [0, 1]:take_while>

Replaces the contents of self with the contents of other_string:

s = 'foo'        # => "foo"
s.replace('bar') # => "bar"

Returns whether self starts with any of the given string_or_regexp.

Matches patterns against the beginning of self. For each given string_or_regexp, the pattern is:

Returns true if any pattern matches the beginning, false otherwise:

'hello'.start_with?('hell')               # => true
'hello'.start_with?(/H/i)                 # => true
'hello'.start_with?('heaven', 'hell')     # => true
'hello'.start_with?('heaven', 'paradise') # => false
'тест'.start_with?('т')                   # => true
'こんにちは'.start_with?('こ')              # => true

Related: String#end_with?.

Search took: 5ms  ·  Total Results: 1651