Last active
December 16, 2018 18:12
-
-
Save alexandersazonof/29eda5023417dd10582a8d5bc2e3617f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Дан целочисленный массив. Преобразовать его, вставив перед каждым положительным элементом нулевой элемент | |
number_array = [1, -2, -1, 4] | |
sort_array = number_array.each_with_object([]) do |item , sort_array | | |
sort_array << 0 if item.positive? | |
sort_array << item | |
end | |
puts sort_array |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
🥇