chomp方法

chomp方法属于String类里面的:

"hello".chomp            #=> "hello"
"hello
".chomp          #=> "hello"
"hello
".chomp        #=> "hello"
"hello

".chomp        #=> "hello
"
"hello
".chomp          #=> "hello"
"hello 
 there".chomp   #=> "hello 
 there"
"hello".chomp("llo")     #=> "he"


chomp方法是移除字符串尾部的分离符,例如 , 等,详细的见官网说明点击打开链接

原文地址:https://www.cnblogs.com/keanuyaoo/p/3279678.html