From: "Marvin Gülker" Date: 2010-08-05T05:14:09+09:00 Subject: Re: A little problem -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Am 04.08.2010 21:57, schrieb Amir Ebrahimifard: > Hi > What is difference between these 2 codes ? > (when I executed these codes result was the same ) > > --------------------- > def welcome1( name ) > puts "Hello#{name}" > end > > def welcome2( name ) > puts "Hello"+name > end > > welcome1( Amir ) > welcome2( Amir ) > > --------------------- Try this: welcome1(3) welcome2(3) You'll see the difference. It's because a string interpolation as in your first example implicitly calls #to_s on it's result. Vale, Marvin -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iQEcBAEBAgAGBQJMWcoKAAoJEDJbypbtvoeic8sH/2xCN2tgVbPe4r876DL/qzp9 1yy7s3mp/42o4C7D4UjRTR1FLZ8gi34EBJy544CAAgOYzBscE0sR7hqp2WxHEPjt WjuB0DTDCBimRF4KJYft2gCwK7ilvTWQMShQYIykS8BHH+KDF7oVLU6W0RjQGwbu 2rCtaHmO68DLIZK/YCBhNP/5T/MVf6jv+9o6KPsWzBTCirsr0G4IiiN9ME98KMoM tI8A7wLOfdhX1K97yJtGEcrhObtNWLKdy8b/mkoK5ejN2+4WPhLVLmhzez3V/X1d 11277TdGvmmpWBBfPfmJ0FJeca78mb5td5zaFhIhTbf7hUrpH6rXII+0xWU9oK4= =NW9K -----END PGP SIGNATURE-----