Hi sms,
What you said I didnot understand in the previous mail but however I came to 
know the mystery of "+".

For finding the answer I went to Scala channel of IRC.and here is the log.
[19:20] <rkg> Hi
[19:20] <RSchulz> Finally! I thought maybe the Earth was finally deserted.
[19:21] <rkg> I've got a doubt about + operaor 
[19:21] <rkg> *operator 
[19:21] <rkg> on String
[19:21] <RSchulz> You doubt it exists?
[19:21] <rkg> yes
[19:21] <rkg> I serched through 
[19:21] <RSchulz> Why?
[19:21] <rkg> the API
[19:21] <rkg> when I add "a"+"b"
[19:21] <rkg> I get "ab"
[19:22] <RSchulz> Looks pretty real to me.
[19:22] <rkg> but where is the + method
[19:22] <rkg> implemented
[19:22] <RSchulz> Are you a Java programmer?
[19:22] <-- njbartlett has left this server.
[19:22] <-- hipertracker|off has left this server.
[19:23] <rkg> yes
[19:23] <rkg> it
[19:23] <rkg> should
[19:23] <rkg> be like
[19:23] <rkg> ("a").+("b")
[19:23] <RSchulz> Well, in Java the compiler handles that.
[19:23] <rkg> does it uses the Java + overloaded method???
[19:24] <RSchulz> I'm not 100% sure, but I think in Scala it's the same with 
the addition of an implicit conversion of any value to a String by calling its 
(class's) toString.
[19:25] <rkg> I saw the API for 
[19:25] <rkg> Rich String
[19:25] <rkg> class
[19:25] <rkg> It doesn't provide
[19:25] <rkg> + method
[19:25] <RSchulz> No.
[19:25] <RSchulz> Like I said, the compiler does part of it.
[19:25] --> hipertracker has joined this channel (n=hiper...@193.95.179.200).
[19:26] <rkg> sorry
[19:26] <rkg> I din't get you
[19:26] <RSchulz> Is this idle curiosity, or do you have a reason to care where 
string addition comes from?
[19:27] <rkg> its the curiosity
[19:27] <rkg> ofcourse
[19:27] <rkg> It may help
[19:27] <rkg> someway
[19:28] <paulp_> it's in predef.
[19:28] <paulp_> it's called any2stringadd.
[19:28] <RSchulz> For me, string concatenation is something I use only for 
debugging purposes, anyway.
[19:28] <rkg> ok
[19:28] <rkg> is it a implicit function?
[19:29] <RSchulz> That's why you sometimes get odd diagnostics if there's 
already a + defined on the LHS value's class but it doesn't accept String as 
its argument.
[19:29] <rkg> yeh
[19:29] <RSchulz> Or the actual type of the RHS.
[19:29] <rkg> one  last question
[19:30] <rkg> is a implicit function
[19:30] <rkg> ?
[19:31] <paulp_> rkg: if it weren't implicit you'd be asking us "why am I 
calling any2stringadd", not "how are these added" ?
[19:31] <RSchulz> Yes. You can see the "implicit" keyword in the ScalaDocs.
[19:31] <rkg> Thanks
[19:31] <rkg> everyBody
[19:32] <rkg> Have a good day!

and the answere is
+ is an implicit operator in predef method its name is any2stringadd.
But however that was a terrif question...! :-)
Hope it helps.
Thanks,
RajkumarGoel
www.twitter.com/rajkumargoel
www.latestfever.blogspot.com


Reply via email to