You don't need the case keyword, but Scala does need to know the types.
Up vote 2 down vote favorite share g+ share fb share tw.
Given that there is a functionfooA, B, C( func: (a: A, b: B, c: C) => B) and I want to pass in this function def secondOfThreeA, B, C(a: A, b: B, c: C): B = be I can call foo with foo(secondOfThree) which is ugly, but works fine.. However, I would expect to be able to call foo with something along the lines of foo(case (_, b, _) => b) however this doesn't work. So what's the clean idiomatic scala way of creating a simple unnamed extracting function? Scala idiomatic link|improve this question edited Mar 1 at 23:46 asked Mar 1 at 23:23Heptic46919 94% accept rate.
– Luigi Plinge Mar 1 at 23:44 @LuigiPlinge whoops, sorry. Fixed the signature – Heptic Mar 1 at 23:47.
You don't need the case keyword, but Scala does need to know the types: scala> def fooA, B, C(func: (A, B, C) => B) = ... foo: A, B, C(func: (A, B, C) => B)Nothing scala> fooSymbol, Int, Char((_, b, _) => b) If the types are known to foo, then the call doesn't need to specify them: scala> def foo(func: (Symbol, Int, Char) => Int) = func('a, 2, 'c') + 5 foo: (func: (Symbol, Int, Char) => Int)Int scala> foo((_, b, _) => b) res3: Int = 7.
So if types could be inferred, you can just the simplest: class TrioA, B, C(a: A, b: B, c: C) { def foo(func: (A, B, C) => B): B = func(a, b, c) } println(new Trio(1, "string", 'Symbol). Foo((_, b, _) => b)).
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.