I still think it's hard to get a good grip on everything SCALA has to offer but the more I experiment with SCALA, the more excited i get.
Just for fun I wrote a little standalone object named FileUtils. It has 3 methods which respectively print recursively all files/directories, only files or only directories.
If you start coding conventionally you might end up with something like this:
But if you watch closely the methods are practically the same except for the check which is done before i print the file to the console... And because of this i have to call the same method recursively.
It took me a while to understand how control abstractions work but here is the refactored version.
Think of how this will influence your life as a developer... no more unnecessary code duplications because of some minor differences.
Cheers,
Robby
No comments:
Post a Comment