Hacker News new | past | comments | ask | show | jobs | submit login

In other news C# is exactly as expressive as Rust and Ruby...

    void Main()
    {
	Console.WriteLine(2.Days().Ago());
	Console.WriteLine(4.Days().FromNow());
    }
     
    //This can be a library, mmkay?

    public static class Extensions 
    {
	public static TimeSpan Days(this int days){ return new TimeSpan(days, 0,0,0); }
	public static DateTime FromNow(this TimeSpan howMuch){ return DateTime.Now + howMuch; }
	public static DateTime Ago(this TimeSpan howMuch){ return DateTime.Now - howMuch; }
    }

Results in:

    26/12/2013 22:05:10
    01/01/2014 22:05:10
Is there a better example?



    public static class Extensions {
        public static void Print(this object o) { Console.WriteLine(o); }
    }

    2.Days().Ago().Print();
    4.Days().FromNow().Print();




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: