News for hackers. Stuff that matters.
Re:Responsible Monkeypatching in Ruby by kryptiskt on Friday August 27, 2021 @06:51AM (#28326219)
Funny thing, that construction is actually pretty easy to achieve in buttoned-up and statically typed C# with extension methods:

        static TimeSpan Weeks(this System.Int32 n)
        {
            return new TimeSpan(n*7, 0, 0, 0);
        }

        static DateTime FromNow(this TimeSpan dt)
        {
            return DateTime.Now.Add(dt);
        }

        static void Main(string[] args)
        {
            Console.WriteLine(2.Weeks().FromNow());
        }
Re:Responsible Monkeypatching in Ruby by eloisius on Friday August 27, 2021 @11:21AM (#28328984)
Not bad! I also feel like it’s worth mentioning that in rust you can extend primitive types with traits. I’ve done that to add some bit-munging helpers while working on a toy Game Boy emulator to make it easier to deal with 16- and 8-bit register values like (8, 8).join() and (l, h) = 16.split().
Re:Responsible Monkeypatching in Ruby by joelbluminator on Friday August 27, 2021 @10:32AM (#28328286)
I'm impressed actually.