摘要:
=begin #gets语句在sublime不可运行,在Dos窗口可运行 puts "Enter a value :" val = gets puts val putc "hello" # h #打开、关闭文件 file = File.new("filename","r") #...处理文件 file.close #File.open方法与new类似,但不同点在于File.... 阅读全文
摘要:
#正则表达式 #语法,3种形式 line = "hello ruby" if line =~ /ruby/ puts "line contains 'ruby'" end if line =~ /RUBY/i #在第二个斜杠后面可以添修饰符 puts "line contains 'ruby',忽略大小写" end if line =~ %r!ru... 阅读全文