Results for: "partition"

Set local variable named symbol as obj.

def foo
  a = 1
  bind = binding
  bind.local_variable_set(:a, 2) # set existing local variable `a'
  bind.local_variable_set(:b, 3) # create new local variable `b'
                                 # `b' exists only in binding

  p bind.local_variable_get(:a)  #=> 2
  p bind.local_variable_get(:b)  #=> 3
  p a                            #=> 2
  p b                            #=> NameError
end

This method behaves similarly to the following code:

binding.eval("#{symbol} = #{obj}")

if obj can be dumped in Ruby code.

Returns true if a local variable symbol exists.

def foo
  a = 1
  binding.local_variable_defined?(:a) #=> true
  binding.local_variable_defined?(:b) #=> false
end

This method is the short version of the following code:

binding.eval("defined?(#{symbol}) == 'local-variable'")
No documentation available
No documentation available
No documentation available

Returns the value of a thread local variable that has been set. Note that these are different than fiber local values. For fiber local values, please see Thread#[] and Thread#[]=.

Thread local values are carried along with threads, and do not respect fibers. For example:

Thread.new {
  Thread.current.thread_variable_set("foo", "bar") # set a thread local
  Thread.current["foo"] = "bar"                    # set a fiber local

  Fiber.new {
    Fiber.yield [
      Thread.current.thread_variable_get("foo"), # get the thread local
      Thread.current["foo"],                     # get the fiber local
    ]
  }.resume
}.join.value # => ['bar', nil]

The value “bar” is returned for the thread local, where nil is returned for the fiber local. The fiber is executed in the same thread, so the thread local values are available.

Sets a thread local with key to value. Note that these are local to threads, and not to fibers. Please see Thread#thread_variable_get and Thread#[] for more information.

Invoke self.each with *args. With a block given, the block receives each element and its index; returns self:

h = {}
(1..4).each_with_index {|element, i| h[element] = i } # => 1..4
h # => {1=>0, 2=>1, 3=>2, 4=>3}

h = {}
%w[a b c d].each_with_index {|element, i| h[element] = i }
# => ["a", "b", "c", "d"]
h # => {"a"=>0, "b"=>1, "c"=>2, "d"=>3}

a = []
h = {foo: 0, bar: 1, baz: 2}
h.each_with_index {|element, i| a.push([i, element]) }
# => {:foo=>0, :bar=>1, :baz=>2}
a # => [[0, [:foo, 0]], [1, [:bar, 1]], [2, [:baz, 2]]]

With no block given, returns an Enumerator.

Calls the block once for each element, passing both the element and the given object:

(1..4).each_with_object([]) {|i, a| a.push(i**2) }
# => [1, 4, 9, 16]

{foo: 0, bar: 1, baz: 2}.each_with_object({}) {|(k, v), h| h[v] = k }
# => {0=>:foo, 1=>:bar, 2=>:baz}

With no block given, returns an Enumerator.

Attempts to enter exclusive section. Returns false if lock fails.

For backward compatibility

Ensures that the MonitorMixin is owned by the current thread, otherwise raises an exception.

No documentation available

Glob pattern for require-able plugin suffixes.

Suffixes for dynamic library require-able paths.

Clear default gem related variables. It is for test

Finds the user’s config file

The default signing key path

Like URI.encode_www_form_component, except that ' ' (space) is encoded as '%20' (instead of '+').

Like URI.decode_www_form_component, except that '+' is preserved.

No documentation available
No documentation available

Should be implemented by a extended class.

tsort_each_node is used to iterate for all nodes over a graph.

Should be implemented by a extended class.

tsort_each_child is used to iterate for child nodes of node.

Visit one side of an alias global variable node.

Search took: 5ms  ·  Total Results: 4702