chomp方法属于String类里面的:
"hello".chomp #=> "hello"
"hello\n".chomp #=> "hello"
"hello\r\n".chomp #=> "hello"
"hello\n\r".chomp #=> "hello\n"
"hello\r".chomp #=> "hello"
"hello \n there".chomp #=> "hello \n there"
"hello".chomp("llo") #=> "he"
chomp方法是移除字符串尾部的分离符,例如\n,\r等,详细的见官网说明点击打开链接。