Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions array.rb
Original file line number Diff line number Diff line change
Expand Up @@ -283,5 +283,23 @@ def select # :nodoc:
alias filter select
end
end

if Primitive.rb_builtin_basic_definition_p(:find)
undef :find

def find(if_none_proc = nil) # :nodoc:
Primitive.attr! :inline_block, :c_trace

unless defined?(yield)
return Primitive.cexpr! 'SIZED_ENUMERATOR(self, 0, 0, ary_enum_length)'
end
_i = 0
value = nil
while Primitive.cexpr!(%q{ ary_fetch_next(self, LOCAL_PTR(_i), LOCAL_PTR(value)) })
return value if yield(value)
end
if_none_proc&.call
end
end
end
end
2 changes: 1 addition & 1 deletion hash.c
Original file line number Diff line number Diff line change
Expand Up @@ -4850,7 +4850,7 @@ rb_hash_any_p(int argc, VALUE *argv, VALUE hash)
* h.dig(:hello) # => nil
* h.default_proc = -> (hash, _key) { hash }
* h.dig(:hello, :world)
* # => {:foo=>{:bar=>[:a, :b, :c]}}
* # => {foo: {bar: [:a, :b, :c]}}
*
* Related: {Methods for Fetching}[rdoc-ref:Hash@Methods+for+Fetching].
*/
Expand Down
6 changes: 3 additions & 3 deletions io_buffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -1481,7 +1481,7 @@ rb_io_buffer_locked(VALUE self)
* * for a buffer created from scratch: free memory.
* * for a buffer created from string: undo the association.
*
* After the buffer is freed, no further operations can't be performed on it.
* After the buffer is freed, no further operations can be performed on it.
*
* You can resize a freed buffer to re-allocate it.
*
Expand Down Expand Up @@ -3500,7 +3500,7 @@ memory_not(unsigned char * restrict output, unsigned char * restrict base, size_
* call-seq:
* ~source -> io_buffer
*
* Generate a new buffer the same size as the source by applying the binary NOT
* Generate a new buffer the same size as the source by applying the unary NOT
* operation to the source.
*
* ~IO::Buffer.for("1234567890")
Expand Down Expand Up @@ -3690,7 +3690,7 @@ memory_not_inplace(unsigned char * restrict base, size_t size)
* call-seq:
* source.not! -> io_buffer
*
* Modify the source buffer in place by applying the binary NOT
* Modify the source buffer in place by applying the unary NOT
* operation to the source.
*
* source = IO::Buffer.for("1234567890").dup # Make a read/write copy.
Expand Down
2 changes: 1 addition & 1 deletion lib/bundler/source/git/git_proxy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ def copy_to(destination, submodules = false)
git "fetch", "--force", "--quiet", *extra_fetch_args(ref), dir: destination
end

git "reset", "--hard", @revision, dir: destination
git "reset", "--hard", revision, dir: destination

if submodules
git_retry "submodule", "update", "--init", "--recursive", dir: destination
Expand Down
62 changes: 43 additions & 19 deletions object.c
Original file line number Diff line number Diff line change
Expand Up @@ -2126,28 +2126,52 @@ static VALUE rb_mod_initialize_exec(VALUE module);

/*
* call-seq:
* Module.new -> mod
* Module.new {|mod| block } -> mod
* Module.new -> new_module
* Module.new {|module| ... } -> new_module
*
* Creates a new anonymous module. If a block is given, it is passed
* the module object, and the block is evaluated in the context of this
* module like #module_eval.
* Returns a new anonymous module.
*
* fred = Module.new do
* def meth1
* "hello"
* end
* def meth2
* "bye"
* end
* end
* a = "my string"
* a.extend(fred) #=> "my string"
* a.meth1 #=> "hello"
* a.meth2 #=> "bye"
* The module may be assigned to a name,
* which should be a constant name
* in capitalized {camel case}[https://en.wikipedia.org/wiki/Camel_case]
* (e.g., +MyModule+, not +MY_MODULE+).
*
* With no block given, returns the new module.
*
* MyModule = Module.new
* MyModule.class # => Module
* MyModule.name # => "MyModule"
*
* With a block given, calls the block with the new (not yet named) module:
*
* MyModule = Module.new {|m| p [m.class, m.name] }
* # => MyModule
* MyModule.class # => Module
MyModule.name # => "MyModule"
*
* Output (from the block):
*
* [Module, nil]
*
* The block may define methods and constants for the module:
*
* MyModule = Module.new do |m|
* MY_CONSTANT = "#{MyModule} constant value"
* def self.method1 = "#{MyModule} first method (singleton)"
* def method2 = "#{MyModule} Second method (instance)"
* end
* MyModule.method1 # => "MyModule first method (singleton)"
* class Foo
* include MyModule
* def speak
* MY_CONSTANT
* end
* end
* foo = Foo.new
* foo.method2 # => "MyModule Second method (instance)"
* foo.speak
* # => "MyModule constant value"
*
* Assign the module to a constant (name starting uppercase) if you
* want to treat it like a regular module.
*/

static VALUE
Expand Down