风言枫语  

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等,详细的见官网说明点击打开链接

 

 

posted on 2013-08-24 19:36  风言枫语  阅读(162)  评论(0)    收藏  举报