Skip to content

Instantly share code, notes, and snippets.

@twosevenzero
Created October 20, 2013 13:31
Show Gist options
  • Save twosevenzero/7069684 to your computer and use it in GitHub Desktop.
Save twosevenzero/7069684 to your computer and use it in GitHub Desktop.
How can I fix this seemingly bad pattern.
#
# I hate having to define a new array, run the each loop and then explicitly return the array.
#
# How can I fix this.
#
def rows
rows_as_array = Array.new
@puzzle.each_line do |line|
rows_as_array.push line.gsub(/[\s\|\-\+]/,"").split(//) unless line.start_with?("-")
end
rows_as_array
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment