سؤال

I've got some code that does this:

for d in directories:  
    if d/f1 exists: process d/f1  
    else if d/f2 exists: process d/f2  
    else skip

where "process" in this case is:

read all the lines and save them for later use

What are some idiomatic ways to do this in Scala?

هل كانت مفيدة؟

المحلول

should be something like that?

fileList.filter(Files.exists(_)).forEach(process(_))
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top