In C#, there's a feature called 'Expression-bodied members' which lets you use an expression to satisfy the body of a function/method or property. For instance, instead of writing these...
void PushItem(object item) {
someStack.push(item)
}
int AddFour(int x) {
return x + 4;
}
int SomeProperty{
get{ return _someProperty; }
set{ _someProperty = value; }
}
You can just write these...
void PushItem(object item) => someStack.push(item)
int AddFour(int x) => x + 4;
int SomeProperty{
get => _someProperty;
set => _someProperty = value;
}
Wondering if Swift has anything similar. It really keeps the code nice, lean and readable.