8000 enum #find ifnone parameter can now be non-callable by mrmargolis · Pull Request #186 · ruby/ruby · GitHub
[go: up one dir, main page]

Skip to content

enum #find ifnone parameter can now be non-callable #186

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Changes from 1 commit
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
Prev Previous commit
Correct usage of rb_check_funcall to determine if the default passed …
…to find is callable
  • Loading branch information
mrmargolis committed Oct 5, 2012
commit 38c486c54ad0efcd78ac6d4bb14086438d508d8b
5 changes: 2 additions & 3 deletions enum.c
Original file line number Diff line number Diff line change
Expand Up @@ -219,9 +219,8 @@ enum_find(int argc, VALUE *argv, VALUE obj)
return memo->u1.value;
}
if (!NIL_P(if_none)) {
if (rb_check_funcall(if_none, rb_intern("call"), 0, 0) != Qundef) {
return rb_funcall(if_none, rb_intern("call"), 0, 0);
}
VALUE result = rb_check_funcall(if_none, rb_intern("call"), 0, 0);
if (result != Qundef) return result;
return if_none;
}
return Qnil;
Expand Down
0