[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

chop and chop!

Johnathan Smith

1/8/2008 4:44:00 PM

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
--
Posted via http://www.ruby-....

3 Answers

Johnathan Smith

1/8/2008 4:54:00 PM

0

Johnathan Smith wrote:

> what the difference between chop and chop! commands are.

sorry i meant chomp and chomp!

thanks

--
Posted via http://www.ruby-....

darren kirby

1/8/2008 4:54:00 PM

0

quoth the Johnathan Smith:
> 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
--
darren kirby :: Part of the problem since 1976 :: http://badco...
"...the number of UNIX installations has grown to 10, with more expected..."
- Dennis Ritchie and Ken Thompson, June 1972

Satish

2/18/2014 5:08:00 PM

0

On Tuesday, February 18, 2014 8:59:34 AM UTC-8, Resty Wyse wrote:
> On Tuesday, February 18, 2014 8:20:13 AM UTC-8, sk....@gmail.com wrote:
>
> > https://globalconnections.hsbc.com/us/en/articles/manufacturinginvietnam?utm_source=outbrain&utm_medium=click&utm_content=1&utm_campaign=glob...
>
> > Vietnam: An alternative to China for manufacturing
>
>
>
> Yes, and Pakistan, Bangladesh. and a lot of others around the world.
>
> They all need help. Please do help them as much as you can.

Vietnam isn't an alternative because it needs help. It is an alternative because it can do things cheaper than PRC can.