tag:blogger.com,1999:blog-5089773352404981635.post5711992100713759528..comments2023-10-04T08:15:13.812-07:00Comments on Daily scala: Overcoming Type Erasure in matching 1Anonymoushttp://www.blogger.com/profile/07600430363435495915noreply@blogger.comBlogger7125tag:blogger.com,1999:blog-5089773352404981635.post-72787684885776982792014-10-28T15:34:07.648-07:002014-10-28T15:34:07.648-07:00hard to read your blog without some sort of code s...hard to read your blog without some sort of code syntax highlighting. <br /><br />You should try this: https://gist.github.com/Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-5089773352404981635.post-65050983870374555622013-04-20T13:33:43.614-07:002013-04-20T13:33:43.614-07:00I think I have similar problem as @wethewolves, an...I think I have similar problem as @wethewolves, and I have a code to test against. See <a href="https://gist.github.com/anonymous/5427293" rel="nofollow">the gist</a> do you have a solution?<br /><br />It prints out three WTF's, I expected STRING! STRING! LONG! How to deal with type erasure in this case?<br /><br />Thanks.Ciantichttps://www.blogger.com/profile/09708844807487564418noreply@blogger.comtag:blogger.com,1999:blog-5089773352404981635.post-66807352883583963412012-12-05T13:19:16.246-08:002012-12-05T13:19:16.246-08:00I would like to match objects that are a tuple-2 i...I would like to match objects that are a tuple-2 in the form (String, List[MyCustomTrait]) and then use both ._1 and ._2 .. Would it be possible to use this approach ?<br /><br />case (k : Sring, IntList(l)) => <br /><br />did not prove fruitful. thanks <br />wethewolveshttps://www.blogger.com/profile/13712631577168133693noreply@blogger.comtag:blogger.com,1999:blog-5089773352404981635.post-45117524778720276122012-06-28T09:09:29.666-07:002012-06-28T09:09:29.666-07:00This comment has been removed by the author.Anonymoushttps://www.blogger.com/profile/01022129834758423202noreply@blogger.comtag:blogger.com,1999:blog-5089773352404981635.post-52226693354252956682011-03-29T02:40:08.644-07:002011-03-29T02:40:08.644-07:00Hi,
Looks like it doesn't work with
new Def[F...Hi,<br />Looks like it doesn't work with <br />new Def[Function1[Int,Unit]]Yaroslav Klymkohttps://www.blogger.com/profile/00054887370355606880noreply@blogger.comtag:blogger.com,1999:blog-5089773352404981635.post-45836596326573121062010-01-29T03:09:00.653-08:002010-01-29T03:09:00.653-08:00Awesome point. I have a new post addressing thisAwesome point. I have a new post addressing thisAnonymoushttps://www.blogger.com/profile/07600430363435495915noreply@blogger.comtag:blogger.com,1999:blog-5089773352404981635.post-26452921598735654602010-01-28T09:06:33.124-08:002010-01-28T09:06:33.124-08:00Is there a way to deal with some type arguments be...Is there a way to deal with some type arguments being contravariant? Try the following:<br /><br />class A<br /><br />class B extends A<br /><br />val AAFunction = new Def[Function1[A,A]]<br /><br />((a:A) => a) match {case AAFunction(f) => Some(f(new A)); case _ => None} // this is OK<br /><br />((a:A) => new B) match {case AAFunction(f) => Some(f(new A)); case _ => None} // this is OK<br /><br />((b:B) => b) match {case AAFunction(f) => Some(f(new A)); case _ => None} // gives a ClassCastException, since new A is not a BBrian Howardhttps://www.blogger.com/profile/12243565006973531593noreply@blogger.com