Branch
Hash :
8541db2e
Author :
Date :
2021-08-09T11:45:09
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105
func greetAgain(person: String) -> String {
return "Hello again, " + person + "!"
}
print(greetAgain(person: "Anna"))
func someFunction<T: SomeClass, U: SomeProtocol>(someT: T, someU: U) {
// function body goes here
}
// none of the below are functions
subscript(index: Int) -> Int {
get {}
set(newValue) {}
}
----------------------------------------------------
[
["keyword", "func"],
["function-definition", "greetAgain"],
["punctuation", "("],
"person",
["punctuation", ":"],
["class-name", "String"],
["punctuation", ")"],
["operator", "->"],
["class-name", "String"],
["punctuation", "{"],
["keyword", "return"],
["string-literal", [
["string", "\"Hello again, \""]
]],
["operator", "+"],
" person ",
["operator", "+"],
["string-literal", [
["string", "\"!\""]
]],
["punctuation", "}"],
["function", "print"],
["punctuation", "("],
["function", "greetAgain"],
["punctuation", "("],
"person",
["punctuation", ":"],
["string-literal", [
["string", "\"Anna\""]
]],
["punctuation", ")"],
["punctuation", ")"],
["keyword", "func"],
["function-definition", "someFunction"],
["operator", "<"],
["class-name", "T"],
["punctuation", ":"],
["class-name", "SomeClass"],
["punctuation", ","],
["class-name", "U"],
["punctuation", ":"],
["class-name", "SomeProtocol"],
["operator", ">"],
["punctuation", "("],
"someT",
["punctuation", ":"],
["class-name", "T"],
["punctuation", ","],
" someU",
["punctuation", ":"],
["class-name", "U"],
["punctuation", ")"],
["punctuation", "{"],
["comment", "// function body goes here"],
["punctuation", "}"],
["comment", "// none of the below are functions"],
["keyword", "subscript"],
["punctuation", "("],
"index",
["punctuation", ":"],
["class-name", "Int"],
["punctuation", ")"],
["operator", "->"],
["class-name", "Int"],
["punctuation", "{"],
["keyword", "get"],
["punctuation", "{"],
["punctuation", "}"],
["keyword", "set"],
["punctuation", "("],
"newValue",
["punctuation", ")"],
["punctuation", "{"],
["punctuation", "}"],
["punctuation", "}"]
]