←back to thread

611 points LorenDB | 2 comments | | HN request time: 0s | source
1. karel-3d ◴[] No.43913292[source]
Well, if you don't want to confuse parameters, you should use Objective-C.

You would do

[orderbook sendOrderWithSymbol:"foo" buy:true quantity:100 price:1000.00]

Cannot confuse that!

(I never used swift, I think it retains this?)

replies(1): >>43922569 #
2. int_19h ◴[] No.43922569[source]
Swift does retain this, but it makes it look much more readable. The example above would be something like:

  orderbook.sendOrder(symbol: "foo", buy: true, quantity: 100, price: 1000.00);
It also has a nifty syntax for function declarations to allow decoupling the keyword from the variable name when that leads to more readable code:

  func parseInt(from s: String) -> Int {
    /* the variable is named 's' here */
  }

  parseInt(from: "123")