Skip to content

Instantly share code, notes, and snippets.

@tikidunpon
Created November 22, 2014 08:28
Show Gist options
  • Save tikidunpon/6b1cef19827ef93c945d to your computer and use it in GitHub Desktop.
Save tikidunpon/6b1cef19827ef93c945d to your computer and use it in GitHub Desktop.
1> "100".toInt()
$R0: Int? = 100
2> var a = 250
a: Int = 250
3> func sum(val1:Int, val2:Int)->Int{
4. return val1 + val2
5. }
6>
7> sum(10, 20)
$R1: Int = 30
8> let result = sum($R0, a)
repl.swift:8:18: error: value of optional type 'Int?' not unwrapped; did you mean to use '!' or '?'?
let result = sum($R0, a)
^
!
8> let result = sum($R0!, a)
9.
result: Int = 350
9> result = 500
repl.swift:9:8: error: cannot assign to 'let' value 'result'
result = 500
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment