FAQ Database Discussion Community


Scala: Access optional value in optional object

scala,error-handling,optional,forced-unwrapping,unwrap
Is there a good way to access a Option Value inside a Option Object? The nested match cases result in a ugly tree structure. So if I have for example: case class MyObject(value: Option[Int]) val optionObject : Option[MyObject] = Some(MyObject(Some(2)) The only way I know to access the value would...

Weird “fatal error: unexpectedly found nil while unwrapping an Optional value”

ios,swift,optional,unwrap
I have 6x UIImageView in my ViewController. I also have tap gestures assigned to them. When the user taps an image, segue is performed. I add those ImageViews to array and that's where an app crashes: @IBOutlet weak var p0: UIImageView! @IBOutlet weak var p1: UIImageView! @IBOutlet weak var p2:...

Multiple unwrap of optionals

swift,optional,unwrap
I have an object, let's say its called "Event". Event has several optionals. struct Event { var name: String! var location: String? var attendees: [String]? var dresscode: String? var startDate: NSDate! var endDate: NSDate? var description: String { return "Name: \(name). Location: \(location). Attendees: \(attendees). Dresscode: \(dresscode). Start date: \(startDate)....