Skip to content

Instantly share code, notes, and snippets.

@j5ik2o
Last active August 29, 2015 14:15
Show Gist options
  • Save j5ik2o/b15f6fe58c6364fc80fc to your computer and use it in GitHub Desktop.
Save j5ik2o/b15f6fe58c6364fc80fc to your computer and use it in GitHub Desktop.
public static boolean isNameHasUpperCase(String name) {
boolean result = false;
for(int i = 0; i < name.length(); i++) {
if (Character.isUpperCase(name.charAt(i))) {
result = true;
break;
}
}
return result;
}
def isNameHasUpperCase(name: String): Boolean =
name.exists(_.isUpperCase)
val name: String = "Junichi Kato"
val name = "Junichi Kato" // 型推論を使った記述
case class Person(name: String)

object PersonDao {
  def getById(id: Long): Option[Person] = {
    // select * from person
  }
}

val personOpt = PersonDao.getById(123)
personOpt.foreach{ person =>
  println(person)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment