Hacker News new | ask | show | jobs
by pitterpatter 2602 days ago
Re: your second example, once upon a time you could write something very similar in Rust:

  do 5.times {
    // ...
  }
Where do was just sugar for calling functions that took a closure as the last argument:

  fn foo(a: A, ..., z: Z, cl: ||) { ... }

  foo(a, ..., z, || {
    ...
  })

  do foo(a, ..., z) {
    ...
  }
1 comments

In fact, before the current for ... in ... syntax, this is how foreach looping used to be done:

  do some_array.each |item| {
    ...
  }