Skip to content

Instantly share code, notes, and snippets.

@alexandersazonof
Last active December 2, 2018 12:27
Show Gist options
  • Save alexandersazonof/598de14a3a55b6de21f49c65989ac6a2 to your computer and use it in GitHub Desktop.
Save alexandersazonof/598de14a3a55b6de21f49c65989ac6a2 to your computer and use it in GitHub Desktop.
#Дана строка в которой записаны слова через пробел. Необходимо посчитать количество слов.
str = "one two three four five"
puts str.split.size
@aya-soft
Copy link

Обычно принято делать цепочку вызовов на одной строчке, если промежуточные переменные не используются больше нигде
array = str.split " "
puts array.size

@aya-soft
Copy link

aya-soft commented Dec 2, 2018

🥇

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