commit
15c0b56c00
|
@ -0,0 +1,123 @@
|
|||
{
|
||||
"id": "swift_cheat_sheet",
|
||||
"name": "Swift",
|
||||
"description": "A quick reference of Apple's Swift language, a multi-paradigm, compiled programming language",
|
||||
"template_type": "terminal",
|
||||
"aliases":["apple swift","swift language"],
|
||||
"metadata": {
|
||||
"sourceName": "GitHub",
|
||||
"sourceUrl": "http://kpbp.github.io/swiftcheatsheet/"
|
||||
},
|
||||
"section_order": [
|
||||
"Basics",
|
||||
"Logical Operators",
|
||||
"Printing",
|
||||
"Dictionaries",
|
||||
"Conditionals",
|
||||
"Loops",
|
||||
"Functions",
|
||||
"Classes"
|
||||
],
|
||||
"sections": {
|
||||
"Basics": [
|
||||
{
|
||||
"key": "var myInt",
|
||||
"val": "Declare a new variable"
|
||||
},
|
||||
{
|
||||
"key": "let myInt = 1",
|
||||
"val": "Declare a new constant"
|
||||
},
|
||||
{
|
||||
"key": "var myString ",
|
||||
"val": "Declare a new string"
|
||||
},
|
||||
{
|
||||
"key": "var colors = \\[\"red\", \"blue\"\\]",
|
||||
"val": "Declares a new string array"
|
||||
}
|
||||
],
|
||||
"Logical Operators": [
|
||||
{
|
||||
"key": "&& ",
|
||||
"val": "AND"
|
||||
},
|
||||
{
|
||||
"key": "|| ",
|
||||
"val": "OR"
|
||||
},
|
||||
{
|
||||
"key": "!=",
|
||||
"val": "Not equals"
|
||||
},
|
||||
{
|
||||
"key": "==",
|
||||
"val": "Equals"
|
||||
}
|
||||
],
|
||||
"Printing": [
|
||||
{
|
||||
"key": "println(\"Hello\")",
|
||||
"val": "Prints Hello"
|
||||
},
|
||||
{
|
||||
"key": "print(\"Hi\")",
|
||||
"val": "Prints Hi"
|
||||
}
|
||||
],
|
||||
"Dictionaries": [
|
||||
{
|
||||
"key": "var days = \\[\"mon\": \"monday\", \"tue\": \"tuseday\"\\]",
|
||||
"val": "Declare a new dictionary"
|
||||
},
|
||||
{
|
||||
"key": "days\\[\"tue\"\\] = \"tuesday\" ",
|
||||
"val": "Change the value for key \"tue\""
|
||||
},
|
||||
{
|
||||
"key": "days.removeValueForKey(\"mon\") ",
|
||||
"val": "Remove \"mon\" from the dictionary"
|
||||
},
|
||||
{
|
||||
"key": "days\\[\"tue\"\\] = nil",
|
||||
"val": "Remove \"tue\" from the dictionary"
|
||||
}
|
||||
],
|
||||
"Conditionals": [
|
||||
{
|
||||
"key": "if condition \\{ //statements\\} ",
|
||||
"val": "If statement"
|
||||
},
|
||||
{
|
||||
"key": "if condition \\{//statements\\} else \\{statements\\}",
|
||||
"val": "If...Else statement"
|
||||
},
|
||||
{
|
||||
"key": "switch control expression \\{case pattern 1: statements case pattern 2: statements default: statements\\}",
|
||||
"val": "Switch"
|
||||
}
|
||||
],
|
||||
"Loops": [
|
||||
{
|
||||
"key": "for var index = 1; index < n; ++index \\{//statements\\}",
|
||||
"val": "For loop"
|
||||
},
|
||||
{
|
||||
"key": "while count < n \\{//statements\\}",
|
||||
"val": "While Loop"
|
||||
}
|
||||
],
|
||||
"Functions": [
|
||||
{
|
||||
"key": "func sayHello(personName: String) -> String \\{//statements\\}",
|
||||
"val": "Function definition"
|
||||
}
|
||||
],
|
||||
"Classes": [
|
||||
{
|
||||
"key": "class SomeClass \\{// class definition\\}",
|
||||
"val": "Define a new class"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue