> For the complete documentation index, see [llms.txt](https://george-jen.gitbook.io/data-science-and-apache-spark/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://george-jen.gitbook.io/data-science-and-apache-spark/scala-methods.md).

# Methods

### Methods

```
def add(x: Int, y: Int): Int = x + y
println(add(1, 2)) // 3
def addThenMultiply(x: Int, y: Int)(multiplier: Int): Int = (x + y)*multiplier 
println(addThenMultiply(1, 2)(3)) // 9
def getSquareString(input: Double): String = {
val square = input*input
square.toString
}
println(getSquareString(2.5)) // 6.25
```

The last expression in the body is the method’s return value, or you can explicitly use return keyword to return from method anywhere.

```
def getSquareString(input: Double): String = {
val square = input*input
return square.toString
}
```
