first_name = gets.chomp
first_name.capitalize!
first_name.upcase!
first_name.downcase!
print <<EOF # 多行输出 EOF
# 我是注释
#{first_name}
if a < b puts '1' elsif b < a puts '2' end
class Classname
def functionname(params)
puts params
end
end
class1 = Classname.new
class1.functionname('1')
unless
unless false
print 'ok'
else
print 'no'
end
print 'puts' user_input = gets.chomp user_input.downcase! if user_input.include?"s" print 'has s' end
# s -> th user_input.gsub!(/s/,"th")
puts 'okok #{user_input}'
counter = 1 while counter < 11 puts counter counter = counter + 1 end
counter = 1 until counter > 10 print counter counter = counter + 1 end
for num in 1...10 puts num end
i = 20
loop do
i -= 1
print "#{ i }"
break if i <= 0
end
i = 20
loop do
i -= 1
next if i%2 != 0
print "#{i}"
break if i <= 0
end
my_array = [1,2,3,4,5]
numbers = [1, 2, 3, 4, 5]
# one way to loop
numbers.each { |item| puts item }
# another way to loop
numbers.each do |item|
puts item
end
10.times { print 'ok'})
num = 1 while num <= 50 do print num num += 1 end
num = 1 until num > 50 do print num num += 1 end
num = 0 loop do num += 1 print "Ruby!" break if num == 30 end
text.split(",")
puts "Text to search through: "
text = gets.chomp
puts "Word to redact"
redact = gets.chomp
words = text.split(" ")
words.each do |word|
print word
end
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有