Skip to content

Instantly share code, notes, and snippets.

@kaochenlong
Last active October 24, 2018 14:10
Show Gist options
  • Save kaochenlong/121905946c17c94e671c7edda3e4e68f to your computer and use it in GitHub Desktop.
Save kaochenlong/121905946c17c94e671c7edda3e4e68f to your computer and use it in GitHub Desktop.
# 練習:請印出從 1 到 100 之間所有的單數。
# 練習:請印出從 1 到 100 之間所有的單數的總和。
# 練習:改良版土砲 times 方法
5.my_times { |i| puts i } # 印出數字 0 ~ 4
# 練習:土砲 select 方法
[1, 2, 3, 4, 5].my_select { |i| i.odd? } # 只印出單數 1, 3, 5
@YanLinGitHub
Copy link

Ruby on Rails Practice Week 2,麻煩龍哥了。

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