Skip to content

Instantly share code, notes, and snippets.

@darya-makarenko
Last active December 16, 2018 21:03
Show Gist options
  • Save darya-makarenko/122cf3b3c16c9296ce1269d3ad8e0637 to your computer and use it in GitHub Desktop.
Save darya-makarenko/122cf3b3c16c9296ce1269d3ad8e0637 to your computer and use it in GitHub Desktop.
puts "Enter the elements of array: (f.e. 1 2 3 4)"
arr = gets.chomp.split.map(&:to_i)
#extracting the first element in array
#pushing it to the last place
arr.push(arr.shift)
puts "The result array: #{arr.join(" ")}"
@aya-soft
Copy link

обычно, если влезает в строку, лучше делать цепочку вызовов.
Как бы ты переписала?

next_elem = arr.shift
#pushing it to the last place
arr.push(next_elem)

@aya-soft
Copy link

🥇

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment