在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
"abc"[0] 返回97 就是a "abc"[1] 98 "abc"[2] 99 "abc"[3] nil "abc"[-1] 99 从后向前数 "abc"[-2] 98 "abc"[-3] 97 "abc"[-4] nil "abc" * 2 返回"abcabc" 支持乘法运算 "abc" + "def" 返回"abcdef" "abcdef"[0,1] "a" 从位置0开始抽取1位 "abcdef"[1,3] "bcd" "abcdef"[-3,3] "def" "abcdef"[1..3] "bc" 从1到3 来一个猜谜语的程序
words = ["hallo","world","lee"]
puts "guess word by \"#{words.join(",")}\"" scret = words[rand(3)] while guess = gets guess.chop! if guess == scret puts "you win" break else puts "you loss,guess?" end end puts "the words is #{scret}" |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论