« Return to Thread: Structural types and generics

Re: Structural types and generics

by Erik Engbrecht :: Rate this Message:

Reply to Author | View in Thread

A function is an object.

http://www.scala-lang.org/docu/files/api/scala/Function1.html

On Mon, Jul 6, 2009 at 5:57 PM, Brian Clapper <bmc@...> wrote:
On 7/6/09 5:42 PM, Viktor Klang wrote:
> Why not try
>
> class StringTemplate(val varRegex : String, val resolver : (String) =>
> Option[String])

Sure, I can do that. In fact, using a function reference did occur to me, as
an alternative to structural typing. But I prefer passing an object rather
than a function, for this particular API. Seems cleaner somehow--though I'll
admit that's a thoroughly subjective judgment.
--
-Brian

Brian Clapper, http://www.clapper.org/bmc/
The IQ of the group is the lowest IQ of a member of the group divided
by the number of people in the group.



--
http://erikengbrecht.blogspot.com/

 « Return to Thread: Structural types and generics