Skip to content

Instantly share code, notes, and snippets.

@achalaggarwal
Created March 16, 2015 13:47
Show Gist options
  • Save achalaggarwal/1ab4c45ac2ab818c62aa to your computer and use it in GitHub Desktop.
Save achalaggarwal/1ab4c45ac2ab818c62aa to your computer and use it in GitHub Desktop.
Mobile TAF 16th March
// Playground - noun: a place where people can play
import UIKit
var str = "Hello, playground"
var name : String? = "Achal"
var namex = name.map { "\($0)" }
var hello = namex ?? ""
var you = name ?? "Vinsol"
you
var range = 1...3
//NSDictionary *dict = @{@"key" : @"value"}
//[@{} mutableCopy]
var dict = ["key":"value", "key2":"value2"]
var dict2: [String:Int] = [:]
var arr = ["hello"]
for key in dict.values {
print(key)
}
[String](dict.keys)
dict.count
arr.count
for x in 1...4 {
// print("My count is %d and the other count is %d", x, x)
print("My count is \(x) and the other count is \(x)")
}
var x:String? = "jell"
x! += "o"
for (var x = 0; x < 10; x++) {
print(x)
}
var stringRange = "aa"..."an"
//func abc() -> () {
// print("hello")
//}
//
//abc()
func abc() -> (x: String, y: String) {
return ("hello", "world")
}
abc()
abc().x
abc().y
func abcd (a: String)(b: String) -> String {
return a + b
}
abcd("hey")(b:" you!")
func swap(inout a:Int, inout b: Int) {
let t = a
a = b
b = t
}
var a = 1
var b = 2
(a,b) = (b,a)
a
b
swap(&a, &b)
a
b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment