Skip to content

Instantly share code, notes, and snippets.

@mandel59
Created January 25, 2012 04:49
Show Gist options
  • Save mandel59/1674786 to your computer and use it in GitHub Desktop.
Save mandel59/1674786 to your computer and use it in GitHub Desktop.
Iteration and interface-less implementations sample
use std;
fn p(i: int) { std::io::println(#fmt("%d", i)) }
impl times for int {
fn times(f: fn(i: int)) { int::range(0, self, f) }
}
fn main() {
10.times {|i| p(i) }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment