Skip to content

Instantly share code, notes, and snippets.

@tpope
Forked from johana-star/find_first_or_nil.rb
Last active September 14, 2015 23:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tpope/762ef57d5fe526441094 to your computer and use it in GitHub Desktop.
Save tpope/762ef57d5fe526441094 to your computer and use it in GitHub Desktop.
A way to fing the first thing that matches or set to nil
grading_period = @context.courses.detect do |course|
gp = GradingPeriod.context_find(course, params[:grading_period_id]) and break gp
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment