mirror of
https://github.com/KevinMidboe/linguist.git
synced 2025-12-08 20:38:47 +00:00
Adds basic support for the Swift programming language
Text only lexer for now until Pygments catches up
This commit is contained in:
20
samples/Swift/section-55.swift
Normal file
20
samples/Swift/section-55.swift
Normal file
@@ -0,0 +1,20 @@
|
||||
class Square: NamedShape {
|
||||
var sideLength: Double
|
||||
|
||||
init(sideLength: Double, name: String) {
|
||||
self.sideLength = sideLength
|
||||
super.init(name: name)
|
||||
numberOfSides = 4
|
||||
}
|
||||
|
||||
func area() -> Double {
|
||||
return sideLength * sideLength
|
||||
}
|
||||
|
||||
override func simpleDescription() -> String {
|
||||
return "A square with sides of length \(sideLength)."
|
||||
}
|
||||
}
|
||||
let test = Square(sideLength: 5.2, name: "my test square")
|
||||
test.area()
|
||||
test.simpleDescription()
|
||||
Reference in New Issue
Block a user