Skip to content

Instantly share code, notes, and snippets.

View stevecass's full-sized avatar

Steven Cassidy stevecass

  • 14:26 (UTC -04:00)
View GitHub Profile
import UIKit
let nonOptionalVar: [String] = ["a", "b", "c"]
let optionalVar:String? = "jimmy"
// this compiles OK with import UIKit present
let ex1: [String: AnyObject] = ["key" : nonOptionalVar, "notherkey": ["content": optionalVar!]]
// Here we forget the ! character that unwraps the optional
// error: contextual type 'AnyObject' cannot be used with dictionary literal
class Post < ActiveRecord::Base
has_many :comments, as: :commentable
end
class Photo < ActiveRecord::Base
has_many :comments, as: :commentable
end
class Comment < ActiveRecord::Base
belongs_to :commentable, polymorphic: true