Skip to content

Instantly share code, notes, and snippets.

View frootloops's full-sized avatar

Arsen Gasparian frootloops

  • Revolut
  • Russia, Moscow
View GitHub Profile
def sum(a : Int32, b : Int32)
a + b
end
sum(1, 1) # 2 : Int32
begin
raise "OH NO!"
rescue
puts "Rescued!"
end
value = "Hello world"
index = value.index("a") # (Int32 | Nil)
if index
# index is not a nil
end
if a.is_a?(Number)
a + 1
end
if 1 + 2 == 3
a = 1
else
a = "hello"
end
a # : Int32 | String
def one
1
end
proc = ->one
proc.call #=> 1
# 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.
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()
App.trackingClient = TestTrackingClient()
let productViewController = ProductViewController(product: product)
productViewController.buy()
App.trackingClient.events[0] == UserEvents.bought(product: product)
class TestTrackingClient: TrackingClientType {
var providers = [TrackingProviderType]()
var events = [TrackingEventType]()
func track(event: TrackingEventType) {
events.append(event)
}
}