3 ms·
What are scala people's opinion of nested functions? Is it good practice to use them? I never liked them because it clutters up the functions and makes them big
by meowzero 11y ago
What are scala people's opinion of nested functions? Is it good practice to use them? I never liked them because it clutters up the functions and makes them bigger. I like have short functions. And looking for them in the code isn't really a problem.
- nullspace 11y agoI started writing an explanation about how nested functions are great, but at some point you stop making a distinction between `val a: A` and `val a: A => B` in the scope of a def. A bunch of my code is interspersed with these function vals. It's useful when within a function when you repeatedly apply the same transformation in multiple places. It kinda makes the code easier to read once you stop making that distinction. re:short functions - I am not as much in favor of them as I used to be before. IMO, splitting functions into smaller ones are fine as long as there is some "meaning" to splitting them ( mostly related to your domain logic ). But I have stopped splitting functions just to make it smaller. When your code is referentially transparent, I think the size of your function really matters less.