[swift-evolution] Overloading assignment operator
stephen.celis at gmail.com
Mon Dec 7 09:38:15 CST 2015
For what it's worth, you can accomplish a lot of assignment operator
overload behavior via property get/set/willSet/didSet (similar to how Ruby
methods suffixed with "=" are dispatched via dot notation), though it would
require you to design your interface so that "=" is called on a property.
On Mon, Dec 7, 2015 at 9:15 AM, Don Wills via swift-evolution <
swift-evolution at swift.org> wrote:
> Thanks to all who replied. I apologize that my responses were disjoint -
> my spam checker delayed a couple of the messages until this morning.
> To those who suggested literal convertibles, I believe Stephen is correct
> in that it is insufficient to accomplish the semantics that I want with the
> syntax I had hoped for. It is about more than just initialization. I'll
> probably just use ":=" as the assignment operator. Not optimal, but it
> > On Dec 6, 2015, at 11:59 AM, Stephen Celis <stephen.celis at gmail.com>
> > I think that his number assignment (via `<~`) depends on the current
> state of `amount`, and that using FloatLiteralConvertible does not provide
> enough information at the call site (since the current value is not
> available in the initializer).
> swift-evolution mailing list
> swift-evolution at swift.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the swift-evolution