Created by Wang, Jerry on Oct 08, 2015
看個Scala的例子:
package method
/**
* @author I042416
*/
class booleaMethod {
private var firstName = ""
private var lastName = ""
def this(first: String, last: String) { // this is an Auxiliary constructor
this() // call primary constructor
this.firstName = first
this.lastName = last
}
def printArgs(args: Array[String]): Integer = {
args.foreach(println)
return args.length
}
def getName( bGetfullName: Boolean): String = {
if( bGetfullName) {
this.firstName + " " + this.lastName
}
else{
this.firstName
}
object testBoolean extends App {
val booleanMethod = new booleaMethod("Jerry", "Wang")
println(booleanMethod.getName(bGetfullName = false))
println(booleanMethod.getName(bGetfullName = true))
産生一個内部類: