Top things I miss in C#
- Null coalescing operator
- Tuple Construction/Deconstruction
- Algebraic data types/Pattern matching
- List comprehensions/array slicing
- Operators in interfaces
After 10 years of C# I really feel that F# is the future.
- Null coalescing operator
- Tuple Construction/Deconstruction
- Algebraic data types/Pattern matching
- List comprehensions/array slicing
- Operators in interfaces
After 10 years of C# I really feel that F# is the future.
var t = new Tuple<int, int>(1, 2);
I apologize if I misunderstood you. var p = SomeFunc();
print("X value is "+p.X);
You would do this (x, y) = SomeFunc();
print("X value is "+x);First sample is C#?
Today you write something like this
var street = (user != null && user.Address != null) ? user.Address.Street : null;
When you could use something like this var street = user?.Address?.Street; public static TReturn Try<TType, TReturn>(this TType value, Func<TType, TReturn> accessor)
{
if (value == null) return default(TReturn);
return accessor(value);
}
The compiler should infer the generic types for you: var street = user.Try(_ => _.Address).Try(_ => _.Street);
Sure the syntactic sugar is nicer but the extension method's not that much worse.