Linked Questions
15 questions linked to/from What are the differences between functions and methods in Swift?
2187 votes
42 answers
1.0m views
What's the difference between a method and a function?
Can someone provide a simple explanation of methods vs. functions in OOP context?
1280 votes
37 answers
631k views
What is an example of the Liskov Substitution Principle?
I have heard that the Liskov Substitution Principle (LSP) is a fundamental principle of object oriented design. What is it and what are some examples of its use?
1002 votes
18 answers
195k views
What is the difference between a 'closure' and a 'lambda'?
Could someone explain? I understand the basic concepts behind them but I often see them used interchangeably and I get confused. And now that we're here, how do they differ from a regular function?
491 votes
9 answers
202k views
Static vs class functions/variables in Swift classes?
The following code compiles in Swift 1.2: class myClass { static func myMethod1() { } class func myMethod2() { } static var myVar1 = "" } func doSomething() { myClass....
394 votes
16 answers
135k views
Why are only final variables accessible in anonymous class?
a can only be final here. Why? How can I reassign a in onClick() method without keeping it as private member? private void f(Button b, final int a){ b.addClickHandler(new ClickHandler() { ...
213 votes
13 answers
97k views
structure vs class in swift language
From Apple book "One of the most important differences between structures and classes is that structures are always copied when they are passed around in your code, but classes are passed by reference....
154 votes
6 answers
34k views
How to use Swift @autoclosure
I noticed when writing an assert in Swift that the first value is typed as @autoclosure() -> Bool with an overloaded method to return a generic T value, to test existence via the LogicValue ...
61 votes
9 answers
27k views
Escaping Closures in Swift
I'm new to Swift and I was reading the manual when I came across escaping closures. I didn't get the manual's description at all. Could someone please explain to me what escaping closures are in Swift ...
91 votes
3 answers
23k views
Subclass UIApplication with Swift
In Objective C it was simple: it was sufficient to update the main.m file and change the UIApplicationMain() parameters return UIApplicationMain(argc, argv, NSStringFromClass([CustomUIApplication ...
82 votes
7 answers
50k views
Missing argument label 'xxx' in call
func say(name:String, msg:String) { println("\(name) say \(msg)") } say("Henry","Hi,Swift") // error: missing argument label 'msg' in call I need to use say("...
37 votes
10 answers
8k views
Java memory model - can someone explain it?
For years and years, I've tried to understand the part of Java specification that deals with memory model and concurrency. I have to admit that I've failed miserably. Yes' I understand about locks and ...
38 votes
3 answers
19k views
What is the difference between a Functor and a Monad?
There are similar questions here but they are attached to a particular programming language and I am looking for an answer on the conceptual level. As I understand, Functors are essentially immutable ...
8 votes
3 answers
6k views
What is the difference between a property and a variable in Swift?
From a few initial tutorials, I see that properties belong to a Class and are essentially 'global variables' as used in the C++ world (coded in this years ago). I also see variables as more of a '...
4 votes
6 answers
908 views
Swift gives syntax error while func calling
I am new in swift and I am following apples doc for studying it. apple doc func greet(name: String, day: String) -> String { return "Hello \(name), today is \(day)." } greet("Bob", day: "...
0 votes
2 answers
76 views
Forced to use parameter names, but only some of them [duplicate]
I'm new to Swift and I've read the Swift Function Documentation and as far as I understand a function has to be built this way: func funcName(param1:Type, param2:Type) -> Return { //Whatever ...