## Swift mode

// // TipCalculatorModel.swift // TipCalculator // // Created by Main Account on 12/18/14. // Copyright (c) 2014 Razeware LLC. All rights reserved. // import Foundation class TipCalculatorModel { var total: Double var taxPct: Double var subtotal: Double { get { return total / (taxPct + 1) } } init(total: Double, taxPct: Double) { self.total = total self.taxPct = taxPct } func calcTipWithTipPct(tipPct: Double) -> Double { return subtotal * tipPct } func returnPossibleTips() -> [Int: Double] { let possibleTipsInferred = [0.15, 0.18, 0.20] let possibleTipsExplicit:[Double] = [0.15, 0.18, 0.20] var retval = [Int: Double]() for possibleTip in possibleTipsInferred { let intPct = Int(possibleTip*100) retval[intPct] = calcTipWithTipPct(possibleTip) } return retval } func funWithStrings() { var numLines = 3 print("This is a string!") print(""" This is a multi-line string! """) print("The preceding string had \(numLines) lines!") } }

A simple mode for Swift

MIME types defined: `text/x-swift` (Swift code)