I want to get value from function that passed as parameter and returns Option[Int], after that if I have None throw an exception and in any other case return value I tried to do like this:
def foo[T](f: T => Option[Int]) = {
   def helper(x: T) = f(x)
   val res = helper _
   res match {
       case None => throw new Exception()
       case Some(z) => z
}
I call it like this:
val test = foo[String](myFunction(_))
test("Some string")
I have compilation error with mismatched types in match section (Some[A] passed - [T] => Option[Int] required) As I understood res variable is reference to the function and I cannot match it with optional either call get\gerOrElse methods. Moreover I probably just dont get how the underscore works and doing something really wrong, I'm using it here to pass a something as parameter to function f, can you explain me where I made a mistake?
 
    