tag:blogger.com,1999:blog-5089773352404981635.post5345455631780153998..comments2023-10-04T08:15:13.812-07:00Comments on Daily scala: Self Annotation vs inheritanceAnonymoushttp://www.blogger.com/profile/07600430363435495915noreply@blogger.comBlogger3125tag:blogger.com,1999:blog-5089773352404981635.post-49122586085819711962013-05-13T10:06:38.895-07:002013-05-13T10:06:38.895-07:00opensas:
scala> class Bar
defined class Bar
sc...opensas:<br />scala> class Bar<br />defined class Bar<br /><br />scala> trait Foo<br />defined trait Foo<br /><br />scala> class FooBar { self: Bar with Foo => }<br />defined class FooBar<br /><br />Unknownhttps://www.blogger.com/profile/02806266229628999057noreply@blogger.comtag:blogger.com,1999:blog-5089773352404981635.post-89752161840618876992012-11-25T07:17:03.303-08:002012-11-25T07:17:03.303-08:00How can yo express more than one dependency?
I tr...How can yo express more than one dependency?<br /><br />I tried with<br /><br />(dep1: Dep1, dep2: Dep2) => {<br />xxx<br />}<br /><br />and it compiles, but it doesn't enforce the dependecies...Anonymoushttps://www.blogger.com/profile/17063247234291086301noreply@blogger.comtag:blogger.com,1999:blog-5089773352404981635.post-39256833339003174382011-09-05T12:04:45.774-07:002011-09-05T12:04:45.774-07:00I am not sure this is the most convincing example ...I am not sure this is the most convincing example for using self types. First off, you could replace both <br /><br />{ self : Properties => <br /><br />with <br /><br />extends Properties {<br /><br />Also, from a modeling perspective, wouldn't it make more sense to switch the self type and inheritance, i.e. have XmlProperties and JSonProperties use self types (since they require the apply method) an have StreamProperties and MapProperties use inheritance (since they supply it)?Cay Horstmannhttps://www.blogger.com/profile/13979366655294015120noreply@blogger.com