Chomp (String) - APIdock
Maybe your like
method chomp ruby latest stable - Class: String chomp(*args)public
Returns a new String with the given record separator removed from the end of str (if present). If $/ has not been changed from the default Ruby record separator, then chomp also removes carriage return characters (that is it will remove n, r, and rn). If $/ is an empty string, it will remove all trailing newlines from the 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" "hello\r\n\r\n".chomp('') #=> "hello" "hello\r\n\r\r\n".chomp('') #=> "hello\r\n\r" Show source static VALUE rb_str_chomp(int argc, VALUE *argv, VALUE str) { VALUE rs = chomp_rs(argc, argv); if (NIL_P(rs)) return rb_str_dup(str); return rb_str_subseq(str, 0, chompped_length(str, rs)); }1Note
Argument Accepted
nhance · Jan 19, 20102 thanksAccepts a single argument record_separator which is the character or string to chomp.
Why isn't this shown in the method def at the top?
Related methods
- Instance methods
- %
- *
- +
- +@
- -@
- <<
- <=>
- ==
- ===
- =~
- []
- []=
- ascii_only?
- b
- block_scanf
- bytes
- bytesize
- byteslice
- capitalize
- capitalize!
- casecmp
- casecmp?
- center
- chars
- chomp
- chomp!
- chop
- chop!
- chr
- clear
- codepoints
- concat
- count
- crypt
- delete
- delete!
- delete_prefix
- delete_prefix!
- delete_suffix
- delete_suffix!
- downcase
- downcase!
- dump
- each_byte
- each_char
- each_codepoint
- each_grapheme_cluster
- each_line
- empty?
- encode
- encode!
- encoding
- end_with?
- eql?
- force_encoding
- freeze
- getbyte
- grapheme_clusters
- gsub
- gsub!
- hash
- hex
- include?
- index
- initialize_copy
- insert
- inspect
- intern
- iseuc
- isjis
- issjis
- isutf8
- kconv
- length
- lines
- ljust
- lstrip
- lstrip!
- match
- match?
- next
- next!
- oct
- ord
- parse_csv
- partition
- prepend
- pretty_print
- replace
- reverse
- reverse!
- rindex
- rjust
- rpartition
- rstrip
- rstrip!
- scan
- scanf
- scrub
- scrub!
- setbyte
- shellescape
- shellsplit
- size
- slice
- slice!
- split
- squeeze
- squeeze!
- start_with?
- strip
- strip!
- sub
- sub!
- succ
- succ!
- sum
- swapcase
- swapcase!
- to_c
- to_d
- to_f
- to_i
- to_r
- to_s
- to_str
- to_sym
- toeuc
- tojis
- tolocale
- tosjis
- toutf16
- toutf32
- toutf8
- tr
- tr!
- tr_s
- tr_s!
- undump
- unicode_normalize
- unicode_normalize!
- unicode_normalized?
- unpack
- unpack1
- upcase
- upcase!
- upto
- valid_encoding?
- Class methods
- new
- try_convert
Tag » What Is Chomp In Ruby
-
Ruby | String Chomp! Method - GeeksforGeeks
-
What Is The Chomp Method In Ruby?
-
How To Use The Ruby Gets & Ruby Chomp Methods - RubyGuides
-
How To Use "gets" And "omp" In Ruby - Stack Overflow
-
Chomp Method In Ruby
-
I Don't Exactly Understand Gets & omp. - Codecademy
-
What Does 'chomp' Mean In Ruby? - Quora
-
Ruby Chomp, Strip, Chop String Examples - Dot Net Perls
-
Ruby Chomp: The Easiest Way To Remove Unwanted New Lines
-
String Chop Vs Chomp - Ruby
-
Class: String (Ruby 3.1.2)
-
TIL: How Does .chomp Method Works? - DEV Community
-
Using Gets, Chomp, To_i, To_f, Math Module And Type Conversion In ...
-
Ruby Programming - 8 - omp Method - YouTube