src/main/scala/bob.scala

1
2
3
4
5
6
7
8
9
10
11
class Bob {
  def hey(message: String) =
    if (message.trim.isEmpty)
      "Fine. Be that way!"
    else if (message.exists(_.isUpper) && !message.exists(_.isLower))
      "Whoa, chill out!"
    else if (message.endsWith("?"))
      "Sure."
    else
      "Whatever."
}

@abo64 thinks this looks great

Comments

Rewritten to use exists for uppercase check - slightly shorter. Also isEmpty for empty test.

helenst commented 9 March 2016 at 09:13 UTC

You're not logged in right now. Please login via GitHub to comment