Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> As soon as things get ambiguous or flexible, go right ahead and specify that your function takes a Map<String,Object>.

Dear god, please don't. Some of the worst spaghetti code I have disentangled used this pattern. Typos in the string literals used as keys, object type mismatches, etc.

If you only want some of the fields from another struct, you have a few options

* Define another struct `FooArgs`. This is easy, and I (respectfully) reject the claim that nobody does it.

* Just define your function to take those two fields directly.



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: