Skip to content

Instantly share code, notes, and snippets.

@Nkzn
Last active August 29, 2015 13:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Nkzn/9560612 to your computer and use it in GitHub Desktop.
Save Nkzn/9560612 to your computer and use it in GitHub Desktop.
package info.nkzn.sample.hogehoge;
public class Greeter {
private String word;
public Greeter(String word) {
this.word = word;
}
public void sayFor(String name) {
System.out.println(
String.format("%s, %s", word, name));
}
public String getWord() {
return word;
}
public void setWord(String word) {
this.word = word;
}
public static void main(String[] args) {
Greeter helloGreeter = new Greeter("Hello");
helloGreeter.sayFor("Nkzn");
Greeter goodMorningGreeter =
new Greeter("Good morning");
goodMorningGreeter.sayFor("NPoi");
}
}
package info.nkzn.sample.hogehoge
public class Greeter(val word: String) {
val sayFor = {
(name : String) ->
println("$word, $name!")
}
}
fun main(args : Array<String>) {
val helloGreeter = Greeter("Hello")
helloGreeter.sayFor("Nkzn")
val goodMorningGreeter =
Greeter("Good morning")
goodMorningGreeter.sayFor("NPoi")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment