Skip to content

Instantly share code, notes, and snippets.

View david-shockley-beeline's full-sized avatar

david-shockley-beeline

View GitHub Profile
parameter_hash.keys.select { |param_name| param_name.to_s =~ /\([0-9]i\)/ }.group_by { |param_name| param_name.match(/(.*)\([0-9]i\)/)[1] }.each do |base_name, full_names|
Used to change for me into:
param_names_ending_with_ni = parameter_hash.keys.select { |param_name| param_name.to_s =~ /\([0-9]i\)/ }
param_names_grouped_by_base_name = param_names_ending_with_ni.group_by { |param_name| param_name.match(/(.*)\([0-9]i\)/)[1] }
param_names_grouped_by_base_name.each do |base_name, full_names|
each loop that content that handles the base_name and full_names stuff I actually want to do something with :)
end