-
Notifications
You must be signed in to change notification settings - Fork 15
Open
Description
// Use .let and forget weird helper methods
val data = DataPoint(1, 22.1, DataPoint(2, 22.8))
val result = data.child?.child?.
let { toFahrenheit(it.celsius) } ?: Double.MIN_VALUE
Let extension could be easily written in c# like this
static class Ext
{
public static TR Let<T, TR>(this T obj, Func<T, TR> func) => func(obj);
}
And then c# example would be pretty similar to kotlin's
var data = new DataPoint(1, 22.1, new DataPoint(2, 22.8));
var result = data.Child?.Child?
.Let(p => ToFahrenheit(p.Celsius)) ?? double.MinValue;
Metadata
Metadata
Assignees
Labels
No labels