9 ms·
It removed the print and returns a list instead.
by moomoo3000 3y ago
It removed the print and returns a list instead.
- Marazan 3y agoWhich is useless because _it has changed the semantics of the function_
- moomoo3000 3y agoIt was a bad function
- byby 3y agoYou have to change the semantics of the function to make it unit testable. Literally tell me how else can you test that function with a unit test? By definition a unit test can only test functions that return data. So there's no other option here.
- Marazan 3y agoLet me tell you your mind is going to be blown once you learn about Monads. A mutable object is functionally identical to a return value if you control the initial state and lifetime of the object. Like you can do in a unit test. And as I demonstrated in my other comment I 100% retained the semantic structure of the function whilst making it 100% unit testable.