Matching patterns might not be the right choice for your example. You can simply do:
if( tokens(1) == "" ) { println("empty") }
Pattern matching is more suitable for situations such as:
for( t <- tokens ) t match { case "" => println( "Empty" ) case s => println( "Value: " + s ) }
which print something for each token.
Edit: if you want to check if there is any token that is an empty string, you can also try:
if( tokens.exists( _ == "" ) ) { println("Found empty token") }
paradigmatic Jul 11 '11 at 8:10 2011-07-11 08:10
source share