This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
OlderNewer