4 ms·
Back when I did C# I found trying to do functional stuff painful. Maybe it's gotten a bit better, but I recall creating functions being something like new Fu
by Touche 11y ago
Back when I did C# I found trying to do functional stuff painful. Maybe it's gotten a bit better, but I recall creating functions being something like
new Func<int> => { stuff here .. }
Or something like that. I found moving to dynamic languages to be a breath of fresh air. I never cared too much about code completion and stuff like that.
- douche 11y agoLambdas and LINQ has made this much simpler: var foo = (param, anotherParam)=>{ /* do stuff */};
- erdeszt 11y agoExcept that this is not working. You have to explicitly type lambdas if you assign them to local variables(or to properties, fields). But I don't see it as big trouble though.
- douche 11y agoWhoops, you're right. Most of the time I'm using them for LINQ filters or maps, or doing quick and dirty event handler delegates. So basically JQuery-esque usage, except with types.
- bratsche 11y agoIf pain is measured in keystrokes, then yeah.. functional C# might be somewhat painful. If you haven't tried it you might consider using F#. It seems to have the best of both worlds. It's got a static type system with functional features, but also a very lightweight and beautiful syntax (heavily influenced by OCaml, fwiw).
- TheCoelacanth 11y agoThat's one way to do it, but the typical way is identical to ES6: `() => expression` or `() => { statements }`