def f
( ints
: Seq
[ Int
] ) : String
= ints
match { "The Seq is empty !"
s"The seq has exactly one element : $first"
case Seq
( first, second
) => s"The seq has exactly two elements : $first, $second"
"The seq has more than two elements"
}
def main
( args
: Array
[ String
] ) : Unit
= { println( f( Seq( ) ) )
println( f( Seq( 1 ) ) )
println( f( Seq( 1 , 2 ) ) )
println( f( Seq( 1 , 2 , 3 ) ) )
println( f( Seq( 1 , 2 , 3 , 4 ) ) )
}
}
b2JqZWN0IE1haW4gewoJCglkZWYgZihpbnRzOiBTZXFbSW50XSk6IFN0cmluZyA9IGludHMgbWF0Y2ggewoJICAJY2FzZSBTZXEoKSA9PgoJICAgICAgCSJUaGUgU2VxIGlzIGVtcHR5ICEiCgkgIAljYXNlIFNlcShmaXJzdCkgPT4KCSAgICAgIAlzIlRoZSBzZXEgaGFzIGV4YWN0bHkgb25lIGVsZW1lbnQgOiAkZmlyc3QiCgkJY2FzZSBTZXEoZmlyc3QsIHNlY29uZCkgPT4KCQkgICAgcyJUaGUgc2VxIGhhcyBleGFjdGx5IHR3byBlbGVtZW50cyA6ICRmaXJzdCwgJHNlY29uZCIKCQljYXNlIF8gPT4KCQkgICAgIlRoZSBzZXEgaGFzIG1vcmUgdGhhbiB0d28gZWxlbWVudHMiCgl9CgoJZGVmIG1haW4oYXJnczogQXJyYXlbU3RyaW5nXSk6IFVuaXQgPSB7CgkJcHJpbnRsbihmKFNlcSgpKSkKCQlwcmludGxuKGYoU2VxKDEpKSkKCQlwcmludGxuKGYoU2VxKDEsIDIpKSkKCQlwcmludGxuKGYoU2VxKDEsIDIsIDMpKSkKCQlwcmludGxuKGYoU2VxKDEsIDIsIDMsIDQpKSkKCX0KCQp9