Getting parameter name from scala function

trait PublicApi{ 

  def sayHi(from:String,content:String) 

} 

I know that it is impossible in java to get "from" and "content" at runtime, but can scala help me here? as a definition

trait PublicApi{ 

  def sayHi(from:String,content:String)(m:Manifest) 

} 

a call to m.methodErasure.getArgumentName (0) will return "from"

+3
source share
2 answers

Signature Scala "HAS these parameter names, you guessed it right. In the end, they must be saved somewhere to use the named / default parameters. You can also use a scalar to view these names.

Feel free to take a look at my preliminary work on the reflection library .

, , , - . , , , ...

+7

ClassManifest - reification, .
:

paranamer ( Monkey ), ( , Java 8.0, Java6!: )

+8

Source: https://habr.com/ru/post/1788766/


All Articles