Dave's Brain

Browse - Programming Tips - How do I declare a function that returns nothing

Date: 2013may14
Language: Scala
Level: Beginner

Q.  How do I declare a function that returns nothing
and a function that returns something in Scala?

A.

def myVoidFunc(param1: String) { // your code here } def myReturnFunc(param1: String): Integer = { // Your code here return 88 // You can use "return" our just the value of the last statement }

Add a comment

Sign in to add a comment
Copyright © 2008-2017, dave - Code samples on Dave's Brain is licensed under the Creative Commons Attribution 2.5 License. However other material, including English text has all rights reserved.