Skip to content

Instantly share code, notes, and snippets.

@marinados
Created May 18, 2016 08:36
Show Gist options
  • Save marinados/4fdab4105aa58da360e98a6818632a13 to your computer and use it in GitHub Desktop.
Save marinados/4fdab4105aa58da360e98a6818632a13 to your computer and use it in GitHub Desktop.

.zipmethod

@array.zip(another_array) do |item1, item2|
    puts "#{item1} #{item2}"
  end

.cycle method for an infinite list of the same character (or turning sth into an endless array)

a = ["a", "b", "c"]
a.cycle { |x| puts x }  # print, a, b, c, a, b, c,.. forever.
a.cycle(2) { |x| puts x }  # print, a, b, c, a, b, c.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment