Ruby11 拾遗
Agenda Loop Expression File Read/Write Debug Process & Thread Loop while a = 10 while a > 0 puts a a -= 1 end until a = 100 until a == 0 puts a a -= 1 end loop a = 10 loop do break if a 0 !~ 正则匹配 是否匹配不到 匹配到返回fals 匹配不到返回true /666/i !~ "hello world" # => true alias 别名 def hello "hello" end alias old_hello hello def hello "new hello" end puts old_hello puts hello File Read/Write 文件读写 File.read File.readlines File#rewind etc IO.read/write File Read file = File.open("run.log", "r") while line = file.gets puts line end File Write file = File.open("run.log", "a+") file.puts "hello" file.close File.open("run.log", "a+") do……