Is this idiom Scala. Making a def to shorten a statement?

function, functional-programming, scala

Solution

Yes, this kind of local methods are perfect for that application. An alternative is to import the instance methods you need in the scope:

def createRecaptchaHtml: String = {
  import Play.current.configuration.getString
  ReCaptchaFactory.newReCaptcha(
    getString("recaptcha.publicKey").get,
    getString("recaptcha.privateKey").get, 
    false
  ).createRecaptchaHtml(null, null)
}

Problem

I'm trying to avoid typing long sentences in the parameter list. Is this an idiom Scala way to archive that? ``` def createRecaptchaHtml: String = { def config(s: String) = Play.current.configuration.getString(s).toString() ReCaptchaFactory.newReCaptcha(config("recaptcha.publicKey") , config("recaptcha.privateKey"), false).createRecaptchaHtml(null, null) ```

Original source