hi,
i know for 99% of you this is a very basic question but i was wondering
what the difference between chop and chop! commands are.
thanks
hi,
i know for 99% of you this is a very basic question but i was wondering
what the difference between chop and chop! commands are.
thanks
Johnathan S. wrote:
what the difference between chop and chop! commands are.
sorry i meant chomp and chomp!
thanks
quoth the Johnathan S.:
hi,
i know for 99% of you this is a very basic question but i was wondering
what the difference between chop and chop! commands are.thanks
Generally with Ruby, methods with the ‘!’ are destructive, and modify
the
receiver in place:
s = “foobar\n”
=> “foobar\n”
s.chop
=> “foobar”
s
=> “foobar\n”
s.chop!
=> “foobar”
s
=> “foobar”
…here you can see ‘chop’ returns a modified copy, leaving ‘s’ intact,
whilst ‘chop!’ modifies ‘s’ directly.
HTH,
-d
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs