Scala method that returns multiple concatenated filter functions -


In my app, I'm filtering a file array in various ways, such as the following:

  val files: array [file] = recurring list files (file) .filter (! _ToString.endsWith ("png")) .Filter (! _ ToString.endsWith ("gif")) .Filter (! .tostring.endsWith ("jpg")) .Filter (! _ToString.endsWith ("jpeg"). Filter (! _ToString.endsWith ("BMP")) .Filter (! _ToString.endsWith ("DB" ))  

But it would be better to define a method that is a string Takes the array and returns all the filters in a similar function. Is this possible? So that I will write

  val files: array [file] = recurring list files (file). Filter (notEndsWith ("png", "gif", "jpg", "jpeg", "bmp" , "Db"))  

You can do something like this:

def notEndsWith (suffix: string *): file = & gt; Boolean = {file = & gt; ! Suffix.exists (file.getName.endsWith)}

Comments

Popular posts from this blog

Eclipse CDT variable colors in editor -

AJAX doesn't send POST query -

wpf - Custom Message Box Advice -