返回顶部

收藏

The while Loop

更多
i = 0
breeds = [ 'q', 'ar', 'ap', 'p' ]
puts breeds.size # => 4
temp = []

while i < breeds.size do
  temp << breeds[i].capitalize
  i +=1
end

temp.sort!
breeds.replace( temp )
p breeds

标签:Ruby,Statement

收藏

0人收藏

支持

0

反对

0

»更多 您可能感兴趣的代码
  1. 2016-12-25 09:38:00unless can work in exactly the same way because unless is just the opposite of if: by Loli控
  2. 2016-01-02 10:26:21Catch and Throw by zetaliang
  3. 2016-09-06 17:38:22downto method with integer by 胡晋
  4. 2016-09-06 20:45:33begin by Loli控
  5. 2016-11-01 09:24:09If vs Case by digua
  6. 2015-12-06 17:14:38All Ruby expressions return a result by 胡晋
  7. 2016-02-09 11:56:59use curly braces ({}): by Loli控
  8. 2016-02-17 20:44:19The if Statement with constant by Jamin
  9. 2016-03-29 16:55:30Nested for loop by 杨洋
  10. 2016-09-06 17:58:38general form of the for loop by Loli控
  11. 2016-09-06 20:50:38throw sends a message to catch if n is less than or equal to 0. by Loli控
相关聚客文章
  1. 博主 发表 2012-12-13 00:00:00 Ruby Range
  2. 博主 发表 2016-04-26 12:00:00 Ruby 2.2.5 Released
  3. 博主 发表 2016-06-29 22:06:42 Ruby - attr_accessor, attr_reader, and attr_writer
  4. techug 发表 2016-08-09 16:22:36 Github:诞生于Ruby,60%的员工远程工作
  5. coder4 发表 2016-10-17 09:21:32 解决ruby的官方gem巨慢的问题
  6. Daniel Lv 发表 2015-03-25 17:10:51 一则 Ruby 和 OpenSSL CA 证书的问题
  7. 博主 发表 2014-06-23 15:23:23 Common Missing Packages for Installing Ruby Gems o
  8. memleaks (IcebergWTF 发表 2017-04-10 10:09:56 memleaks forked cucumber/cucumber-ruby-core to mem
  9. 博主 发表 2017-05-05 11:30:00 Rename a method in Ruby: alias_method and remove_m
  10. xinlu 发表 2017-08-31 15:46:30 Install Ruby on Rails with Rbenv on CentOS 7
  11. 博主 发表 2017-10-05 17:30:45 Lion使用RVM安装ruby
  12. xinlu 发表 2018-01-03 06:23:21 ruby-rails的自启动脚本

发表评论