This is the idiom of Scala. Make a definition to reduce discharge?

I am trying to avoid entering long sentences in the parameter list.
Is this a Scala idiom way of archiving this?

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) 
+6
source share
1 answer

Yes, such local methods are ideal for this application. An alternative is to import the instance methods that 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) } 
+9
source

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


All Articles