Re:Porting 4.5K lines of C to Go
by taspeotis on Saturday August 05, 2017 @06:17AM
(#14935060)
You can also use expression bodied members (that's the => syntax) with get/set. There's a shorthand if you only need to define the getter (i.e. read-only):
[ Parent
| on HN ]
Re:Porting 4.5K lines of C to Go
by DelightOne on Saturday August 05, 2017 @08:28AM
(#14935389)
Swift has the same syntax too except the last line.
Have they introducted willSet and didSet too?
Neat stuff, i may try the language out in a future project on windows.
There's no direct equivalent to willSet or didSet. The closest equivalent (aside from adding code before/after your own get/set code) might be INotifyPropertyChanged [1]/INotifyPropertyChanging [2]? But they are more for external observers and add a lot of boilerplate to your code. It's possible to manage the boilerplate, however [3].
[1] https://msdn.microsoft.com/en-us/library/system.componentmod...
[2] https://msdn.microsoft.com/en-us/library/system.componentmod...