1

I want to do the following but it is not working:

infix operator <=== {}

func <===<T> (inout lhs: T, rhs:ObservableProperty<T>) -> ()
{
    rhs.observe()    
    {
        newValue in
        lhs = newValue
    }
}

ObservableProperty<T> is a custom class I wrote which has an observe() method.

Airspeed Velocity
  • 40,491
  • 8
  • 113
  • 118
aland
  • 41
  • 1
  • 2
  • 1
    _What_ is not working? You’ll stand a better chance of getting an answer if you post a complete working code snippet. – Airspeed Velocity Aug 01 '15 at 12:40
  • If `rhs.observe()` is async call, it's duplicate of http://stackoverflow.com/q/28246949/3804019 – rintaro Aug 01 '15 at 13:44
  • Hi – you should make an edit to your question rather than posting clarification as an answer to it. There is an edit link just underneath each question or answer you can use. However to answer your question: you need to make it an assignment operator not an infix one, and the ampersand won't be required. Take a look at [the documentation](https://developer.apple.com/library/prerelease/ios/documentation/Swift/Conceptual/Swift_Programming_Language/AdvancedOperators.html) for defining operators. – Airspeed Velocity Aug 01 '15 at 23:26

0 Answers0