Method constraints in Scala
Method require allows definition of additional run-time constraints:
def post(tweet: String) = {
  require(tweet.length > 0, "message is too short")
  require(tweet.length < 140, "message is too long")
  println(tweet)
}Written by Eugene Ryzhikov
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
 #Scala 
Authors
Related Tags
#scala
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#