Midwest Dev Chat

MidwestDevChat.com

  • The newest 15 messages in the super-cool #swift channel.

  • 09/20 15:30:33 Lyn:
                if case .success = state {
                    return true
                }
    
                return false
            })
    ```
    
    Is there a better way to write that? I was hoping this would be valid: ```let stuffIsHidden = viewModel.state.map({ state -> Bool in
      return case .success = state
    })```
    
    I could do something like this: ```let stuffIsHidden = viewModel.state.map({ state -> Bool in
      return state == .success
    })
    but only if I overload `==` for `State`.
  • 09/20 15:34:35 Antone: Could put an `isSuccess: Bool` computed property on your state enum, otherwise thats the way i think you have to do it.
  • 09/20 15:47:52 Charita: are you wanting to do something else with the mapped value? I'm not sure why you'd want to wrap your check in a map block when you are just assigning a boolean
  • 09/20 15:48:30 Lyn: `viewModel.state` and `stuffIsHidden` are both ReactiveSwift signal producers
  • 09/20 15:48:35 Charita: or does this get saved as a function to be dynamically invoked later? (new to swift)
  • 09/20 15:48:55 Lyn: so I'm binding a view's `button.reactive.isHidden <~ stuffIsHidden`
  • 09/20 16:07:06 Charita: `State` is an `enum` then? Can you declare it as `Equatable` ? (https://stackoverflow.com/questions/46782139/ho...)
  • 09/20 16:46:13 Lyn: Oh you know, I am indeed in Swift 4.1
  • 09/20 16:46:29 Lyn: that will work great tada
  • *Usernames have been changed to protect the innocent.
We're currently 1103 members strong. Join us!
Request Invite

Check out all the cool channels!

Join the conversation!