This file contains hidden or 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
| def sum(a : Int32, b : Int32) | |
| a + b | |
| end | |
| sum(1, 1) # 2 : Int32 |
This file contains hidden or 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
| begin | |
| raise "OH NO!" | |
| rescue | |
| puts "Rescued!" | |
| end |
This file contains hidden or 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
| value = "Hello world" | |
| index = value.index("a") # (Int32 | Nil) | |
| if index | |
| # index is not a nil | |
| end |
This file contains hidden or 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
| if a.is_a?(Number) | |
| a + 1 | |
| end |
This file contains hidden or 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
| if 1 + 2 == 3 | |
| a = 1 | |
| else | |
| a = "hello" | |
| end | |
| a # : Int32 | String |
This file contains hidden or 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
| def one | |
| 1 | |
| end | |
| proc = ->one | |
| proc.call #=> 1 |
This file contains hidden or 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
| # This is a comment | |
| nil # is used to represent the absence of a value | |
| true # A Bool that is true | |
| false # A Bool that is false | |
| 10 # Int32 | |
| 1.0 # Float64 | |
| 'a' # a Char represents a Unicode code point. It occupies 32 bits. |
This file contains hidden or 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
| protocol TrackingEventType { | |
| var identifier: String { get } | |
| var properties: [String: Any] { get } | |
| } | |
| protocol TrackingProviderType { | |
| func track(event: TrackingEventType) | |
| func associate(with user: User) | |
| func disassociateUser() | |
| func setup() |
This file contains hidden or 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
| App.trackingClient = TestTrackingClient() | |
| let productViewController = ProductViewController(product: product) | |
| productViewController.buy() | |
| App.trackingClient.events[0] == UserEvents.bought(product: product) |
This file contains hidden or 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 TestTrackingClient: TrackingClientType { | |
| var providers = [TrackingProviderType]() | |
| var events = [TrackingEventType]() | |
| func track(event: TrackingEventType) { | |
| events.append(event) | |
| } | |
| } |