Skip to content

Instantly share code, notes, and snippets.

@Ravikharatmal
Created December 16, 2018 04:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Ravikharatmal/6b9555b300342998feb854ecb0a4d63c to your computer and use it in GitHub Desktop.
Save Ravikharatmal/6b9555b300342998feb854ecb0a4d63c to your computer and use it in GitHub Desktop.
Java vs. Groovy, Scala, Kotlin - Syntax Comparison of JVM Languages
Syntax:
<class/object> <class-name> (constructor-arg-name:arg-type,..){
<private/protected/no-modifier> def <func-name> (<arg-name>:<arg-type>,...) : <return-type> = {
<method-body>
return <return-value>
}
}
Example:
class MyTestClass(name: String){
def myMethod(a: String, b: Int): String = {
var result = name + a + b;
return result;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment