class Person{ fun fly(){ println("fly"); } fun walk(){ println("walk"); } fun speak(){ println("speak"); } fun jump(){ println("jump"); } fun run(){ println("run"); } fun eat(){ println("eat"); } fun see(){ println("see"); } fun think(): Pe
class Person{
fun fly(){
println("fly");
}
fun walk(){
println("walk");
}
fun speak(){
println("speak");
}
fun jump(){
println("jump");
}
fun run(){
println("run");
}
fun eat(){
println("eat");
}
fun see(){
println("see");
}
fun think(): Person {
println("think");
return this;
}
fun listener(): Person {
println("listener");
return this;
}
}
var person=Person();
person.listener().think().see();
with(person){
eat()
think()
listener()
run()
fly()
}
listener
think
see
eat
think
listener
run
fly
上面的with可以在里面直接写方法,看起来高大上不过哈哈,然并卵的样子。