ruby chomp_Ruby中的chomp方法

ruby chomp

Ruby排骨方法 (Ruby chomp method)

chomp is a predefined method in Ruby's library which is used to eliminate implicit newline character '\n' attached with the string entered by the user during run time. We use gets method in Ruby for taking input from the user but it provides a new line with the string. chomp provides help to remove it because newline is not desired in the string most of the times as newline creates problems when some time of processing takes place in the string.

chomp是Ruby库中的预定义方法,用于消除运行时用户输入的字符串附带的隐式换行符'\ n' 。 我们在Ruby中使用gets方法从用户处获取输入,但是它为字符串提供了新的一行。 chomp提供了删除它的帮助,因为大多数情况下,字符串中不需要换行符,因为当在字符串中进行某些时间处理时,换行符会产生问题。

Use of chomp


本文来自互联网用户投稿,文章观点仅代表作者本人,不代表本站立场,不承担相关法律责任。如若转载,请注明出处。 如若内容造成侵权/违法违规/事实不符,请点击【内容举报】进行投诉反馈!

相关文章

立即
投稿

微信公众账号

微信扫一扫加关注

返回
顶部