Created
January 25, 2012 04:49
-
-
Save mandel59/1674786 to your computer and use it in GitHub Desktop.
Iteration and interface-less implementations sample
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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