tag:blogger.com,1999:blog-5089773352404981635.post1037858680265945043..comments2023-10-04T08:15:13.812-07:00Comments on Daily scala: Companion Object ImplicitsAnonymoushttp://www.blogger.com/profile/07600430363435495915noreply@blogger.comBlogger3125tag:blogger.com,1999:blog-5089773352404981635.post-5795552215954439902010-04-25T14:59:23.224-07:002010-04-25T14:59:23.224-07:00Dear Jesse,
I put the implicit conversion into a ...Dear Jesse,<br /><br />I put the implicit conversion into a package object now and that indeed did the trick. Thanks for the hint!Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-5089773352404981635.post-57435849450517595972010-04-25T01:36:25.326-07:002010-04-25T01:36:25.326-07:00You are confusing implicit parameter resolution wi...You are confusing implicit parameter resolution with implicit object conversion. Implicit object conversion is potentially dangerous so they normally have to be imported explicitly into scope. <br /><br />Caveats to that is implicit object conversions defined in superclasses and (I am pretty sure) in package objects are automatically in scope. <br /><br />I will address this soon.Anonymoushttps://www.blogger.com/profile/07600430363435495915noreply@blogger.comtag:blogger.com,1999:blog-5089773352404981635.post-9542476566519955212010-04-24T10:41:34.494-07:002010-04-24T10:41:34.494-07:00Speaking of which, why does the following not work...Speaking of which, why does the following not work?<br /><br />class A(i: Int)<br />object A {implicit def int2A(i: Int) = new A(i) }<br />val a: A = 2<br /><br />The implicit conversion is defined in the companion object of the expected type. Which part do I not get?<br /><br />It does of course work if I "import A._", but I'm still looking for a way around that.Anonymousnoreply@blogger.com