Skip to content

Understand Evan's example #2

@DanielSank

Description

@DanielSank

I'm not sure what this is for yet, but Evan said it would be helpful :D

import scala.language.experimental.macros
import scala.reflect.runtime.universe._

object Hi {

 def interrogated(strArg: Array[String], intArg: Int, str2: String) : Int = 4

 def paramInfo[T](x: T)(implicit tag: TypeTag[T]): Unit = {
     val targs = tag.tpe match { case TypeRef(_, _, args) => args }
     println(s"type of $x has type arguments $targs")
 }

 def main(args: Array[String]) = paramInfo(interrogated _)
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions