samedi 29 décembre 2018

Calling Method in Scala from User Input

I have a user input:

val method = """doReplace(doReplace("ab","a","x"),"b","y")"""

How can I invoke this method at run-time using Scala:

object test2 {

  def doReplace(str: String, oldChar: String, newChar: String) = {
    str.replace(oldChar, newChar)
  }

  def main(args: Array[String]): Unit = {

    val method = """doReplace(doReplace("ab","a","x"),"b","y")"""

  }

} 





Aucun commentaire:

Enregistrer un commentaire