Skip to content

Instantly share code, notes, and snippets.

@langford
Created June 5, 2014 01:50
Show Gist options
  • Save langford/c4d4a78673cdf8d660c3 to your computer and use it in GitHub Desktop.
Save langford/c4d4a78673cdf8d660c3 to your computer and use it in GitHub Desktop.
Random test of method overloading
import UIKit
class Square {
var sideLength: Double
init(sideLength: Double, name: String) {
self.sideLength = sideLength
}
init(sideSlipperyness: Double, name: String) {
self.sideLength = 45;
}
func area() -> Double {
return sideLength * sideLength
}
}
class ViewController: UIViewController {
@IBOutlet var metalsView : UIView
@IBOutlet var coalView : UIView
@IBOutlet var lumberView : UIView
@IBOutlet var newGameButton : UIButton
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
self.lumberView.backgroundColor = UIColor.redColor()
self.coalView.backgroundColor = UIColor.blackColor()
self.metalsView.backgroundColor = UIColor.blueColor()
//Method overloading?
let sq1 = Square(sideSlipperyness:4.3,name:"blurt")
let sq2 = Square(sideLength:4.6,name:"blook")
println(sq1.sideLength)
println(sq2.sideLength)
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment