Results for: "remove_const"

Proceed with resolution! Returns an array of ActivationRequest objects.

Returns true if URI does not have a scheme (e.g. http:// or https://) specified.

Returns the replacement string.

ec = Encoding::Converter.new("euc-jp", "us-ascii")
p ec.replacement    #=> "?"

ec = Encoding::Converter.new("euc-jp", "utf-8")
p ec.replacement    #=> "\uFFFD"

Sets the replacement string.

ec = Encoding::Converter.new("utf-8", "us-ascii", :undef => :replace)
ec.replacement = "<undef>"
p ec.convert("a \u3042 b")      #=> "a <undef> b"
No documentation available

Returns the new string formed by calling method #inspect on each array element:

a = [:foo, 'bar', 2]
a.inspect # => "[:foo, \"bar\", 2]"

Related: see Methods for Converting.

Returns a new array that is the union of the elements of self and all given arrays other_arrays; items are compared using eql?:

[0, 1, 2, 3].union([4, 5], [6, 7]) # => [0, 1, 2, 3, 4, 5, 6, 7]

Removes duplicates (preserving the first found):

[0, 1, 1].union([2, 1], [3, 1]) # => [0, 1, 2, 3]

Preserves order (preserving the position of the first found):

[3, 2, 1, 0].union([5, 3], [4, 2]) # => [3, 2, 1, 0, 5, 4]

With no arguments given, returns a copy of self.

Related: see Methods for Combining.

Returns a new array containing each element in self that is #eql? to at least one element in each of the given other_arrays; duplicates are omitted:

[0, 0, 1, 1, 2, 3].intersection([0, 1, 2], [0, 1, 3]) # => [0, 1]

Each element must correctly implement method #hash.

Order from self is preserved:

[0, 1, 2].intersection([2, 1, 0]) # => [0, 1, 2]

Returns a copy of self if no arguments are given.

Related: see Methods for Combining.

Prepends the given objects to self:

a = [:foo, 'bar', 2]
a.unshift(:bam, :bat) # => [:bam, :bat, :foo, "bar", 2]

Related: Array#shift; see also Methods for Assigning.

Inserts the given objects as elements of self; returns self.

When index is non-negative, inserts objects before the element at offset index:

a = ['a', 'b', 'c']     # => ["a", "b", "c"]
a.insert(1, :x, :y, :z) # => ["a", :x, :y, :z, "b", "c"]

Extends the array if index is beyond the array (index >= self.size):

a = ['a', 'b', 'c']     # => ["a", "b", "c"]
a.insert(5, :x, :y, :z) # => ["a", "b", "c", nil, nil, :x, :y, :z]

When index is negative, inserts objects after the element at offset index + self.size:

a = ['a', 'b', 'c']      # => ["a", "b", "c"]
a.insert(-2, :x, :y, :z) # => ["a", "b", :x, :y, :z, "c"]

With no objects given, does nothing:

a = ['a', 'b', 'c'] # => ["a", "b", "c"]
a.insert(1)         # => ["a", "b", "c"]
a.insert(50)        # => ["a", "b", "c"]
a.insert(-50)       # => ["a", "b", "c"]

Raises IndexError if objects are given and index is negative and out of range.

Related: see Methods for Assigning.

With a block given, calls the block with each element of self; returns a new array whose elements are the return values from the block:

a = [:foo, 'bar', 2]
a1 = a.map {|element| element.class }
a1 # => [Symbol, String, Integer]

With no block given, returns a new Enumerator.

Related: collect!; see also Methods for Converting.

With a block given, calls the block with each element of self and replaces the element with the block’s return value; returns self:

a = [:foo, 'bar', 2]
a.map! { |element| element.class } # => [Symbol, String, Integer]

With no block given, returns a new Enumerator.

Related: collect; see also Methods for Converting.

Returns a new array that is self as a transposed matrix:

a = [[:a0, :a1], [:b0, :b1], [:c0, :c1]]
a.transpose # => [[:a0, :b0, :c0], [:a1, :b1, :c1]]

The elements of self must all be the same size.

Related: see Methods for Converting.

Returns a new array containing only the non-nil elements from self; element order is preserved:

a = [nil, 0, nil, false, nil, '', nil, [], nil, {}]
a.compact # => [0, false, "", [], {}]

Related: Array#compact!; see also Methods for Deleting.

Removes all nil elements from self; Returns self if any elements are removed, nil otherwise:

a = [nil, 0, nil, false, nil, '', nil, [], nil, {}]
a.compact! # => [0, false, "", [], {}]
a          # => [0, false, "", [], {}]
a.compact! # => nil

Related: Array#compact; see also Methods for Deleting.

Returns a count of specified elements.

With no argument and no block, returns the count of all elements:

[0, :one, 'two', 3, 3.0].count # => 5

With argument object given, returns the count of elements == to object:

[0, :one, 'two', 3, 3.0].count(3) # => 2

With no argument and a block given, calls the block with each element; returns the count of elements for which the block returns a truthy value:

[0, 1, 2, 3].count {|element| element > 1 } # => 2

With argument object and a block given, issues a warning, ignores the block, and returns the count of elements == to object.

Related: see Methods for Querying.

Iterates over permutations of the elements of self; the order of permutations is indeterminate.

With a block and an in-range positive integer argument count (0 < count <= self.size) given, calls the block with each permutation of self of size count; returns self:

a = [0, 1, 2]
perms = []
a.permutation(1) {|perm| perms.push(perm) }
perms # => [[0], [1], [2]]

perms = []
a.permutation(2) {|perm| perms.push(perm) }
perms # => [[0, 1], [0, 2], [1, 0], [1, 2], [2, 0], [2, 1]]

perms = []
a.permutation(3) {|perm| perms.push(perm) }
perms # => [[0, 1, 2], [0, 2, 1], [1, 0, 2], [1, 2, 0], [2, 0, 1], [2, 1, 0]]

When count is zero, calls the block once with a new empty array:

perms = []
a.permutation(0) {|perm| perms.push(perm) }
perms # => [[]]

When count is out of range (negative or larger than self.size), does not call the block:

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

With no block given, returns a new Enumerator.

Related: Methods for Iterating.

Returns true if no element of self meets a given criterion, false otherwise.

With no block given and no argument, returns true if self has no truthy elements, false otherwise:

[nil, false].none?    # => true
[nil, 0, false].none? # => false
[].none?              # => true

With argument object given, returns false if for any element element, object === element; true otherwise:

['food', 'drink'].none?(/bar/) # => true
['food', 'drink'].none?(/foo/) # => false
[].none?(/foo/)                # => true
[0, 1, 2].none?(3)             # => true
[0, 1, 2].none?(1)             # => false

With a block given, calls the block with each element in self; returns true if the block returns no truthy value, false otherwise:

[0, 1, 2].none? {|element| element > 3 } # => true
[0, 1, 2].none? {|element| element > 1 } # => false

Related: see Methods for Querying.

Returns true if exactly one element of self meets a given criterion.

With no block given and no argument, returns true if self has exactly one truthy element, false otherwise:

[nil, 0].one? # => true
[0, 0].one? # => false
[nil, nil].one? # => false
[].one? # => false

With a block given, calls the block with each element in self; returns true if the block a truthy value for exactly one element, false otherwise:

[0, 1, 2].one? {|element| element > 0 } # => false
[0, 1, 2].one? {|element| element > 1 } # => true
[0, 1, 2].one? {|element| element > 2 } # => false

With argument object given, returns true if for exactly one element element, object === element; false otherwise:

[0, 1, 2].one?(0) # => true
[0, 0, 1].one?(0) # => false
[1, 1, 2].one?(0) # => false
['food', 'drink'].one?(/bar/) # => false
['food', 'drink'].one?(/foo/) # => true
[].one?(/foo/) # => false

Related: see Methods for Querying.

Returns elements from self, or nil; does not modify self.

With no argument given, returns the first element (if available):

a = [:foo, 'bar', 2]
a.first # => :foo
a # => [:foo, "bar", 2]

If self is empty, returns nil.

[].first # => nil

With a non-negative integer argument count given, returns the first count elements (as available) in a new array:

a.first(0)  # => []
a.first(2)  # => [:foo, "bar"]
a.first(50) # => [:foo, "bar", 2]

Related: see Methods for Querying.

Returns elements from self, or nil; self is not modified.

With no argument given, returns the last element, or nil if self is empty:

a = [:foo, 'bar', 2]
a.last # => 2
a # => [:foo, "bar", 2]
[].last # => nil

With non-negative integer argument count given, returns a new array containing the trailing count elements of self, as available:

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

Related: see Methods for Fetching.

Returns a Hash containing implementation-dependent counters inside the VM.

This hash includes information about method/constant caches:

{
  :constant_cache_invalidations=>2,
  :constant_cache_misses=>14,
  :global_cvar_state=>27
}

If USE_DEBUG_COUNTER is enabled, debug counters will be included.

The contents of the hash are implementation specific and may be changed in the future.

This method is only expected to work on C Ruby.

Returns an array with both a numeric and a int represented as Integer objects or Float objects.

This is achieved by converting numeric to an Integer or a Float.

A TypeError is raised if the numeric is not an Integer or a Float type.

(0x3FFFFFFFFFFFFFFF+1).coerce(42)   #=> [42, 4611686018427387904]

Returns a string containing the place-value representation of self in radix base (in 2..36).

12345.to_s               # => "12345"
12345.to_s(2)            # => "11000000111001"
12345.to_s(8)            # => "30071"
12345.to_s(10)           # => "12345"
12345.to_s(16)           # => "3039"
12345.to_s(36)           # => "9ix"
78546939656932.to_s(36)  # => "rubyrules"

Raises an exception if base is out of range.

Returns the value as a rational. The optional argument eps is always ignored.

Search took: 5ms  ·  Total Results: 3316