guard and if let statements are normally only used to unwrap optionals. I'm not really thrilled with this solution, but you could cast scrollView.contentOffset.y as an Optional<CGFloat> to get the behavior you want: