Ruby Like Features of .NET - No Fluff Just Stuff

Ruby Like Features of .NET

Posted by: Venkat Subramaniam on October 30, 2006

Again I thoroughly enjoyed speaking to Carl (he is a great host) about Ruby like features of .NET.
I hope you enjoyed the show as much as I did being on it.

Fifteen minutes after the show (now that's true passion), Milan writes:

Hi Dr. Venkat

I was so exited with your very last show on dnrTV, so I've tried to generalize FindAll method and I'm sending you my code, made 15 minutes after I've seen the show. I don't know if you are interested in it and what will you do about it, but I've just had to share my excitement with someone (I've sent it to Carl also. He's such a good host). So here it goes:

using System;
using System.Collections.Generic;

namespace LambdaGenericsExtenders_Example {
    class Program
    {
        static void Main(string[] args)
        {
            var list = new int[] { 5, 3, 6, 4, 37, 2, 4 };
            var sList = new string[] { "This", "is", "so", "cool", "man", "!" };

            foreach (var i in sList.FindAll(elem => !elem.Contains("is") && elem != "!"))
                Console.WriteLine(i);

            Console.WriteLine("=================");
            foreach (var i in list.FindAll(elem => elem > 3))
                Console.WriteLine(i);

            Console.ReadKey();
        }
    }

    public delegate bool Evaluator<T>(T val);

    public static class Extender
    {
        public static IEnumerable<T> FindAll<T>(this T[] array, Evaluator<T> eval)
        {
            foreach (var val in array)
                if (eval(val))
                    yield return val;
        }
    }
}


---

Sorry if I've disturbed you, but if you continue to have that Great shows, it'll happen again :-)

Thank you for the threat Milan! You're a great inspiration for a lot of us.

Venkat Subramaniam

About Venkat Subramaniam

Dr. Venkat Subramaniam is an award-winning author, founder of Agile Developer, Inc., creator of agilelearner.com, and an instructional professor at the University of Houston.

He has trained and mentored thousands of software developers in the US, Canada, Europe, and Asia, and is a regularly-invited speaker at several international conferences. Venkat helps his clients effectively apply and succeed with sustainable agile practices on their software projects.

Venkat is a (co)author of multiple technical books, including the 2007 Jolt Productivity award winning book Practices of an Agile Developer. You can find a list of his books at agiledeveloper.com. You can reach him by email at venkats@agiledeveloper.com or on twitter at @venkat_s.

Why Attend the NFJS Tour?

  • » Cutting-Edge Technologies
  • » Agile Practices
  • » Peer Exchange

Current Topics:

  • Languages on the JVM: Scala, Groovy, Clojure
  • Enterprise Java
  • Core Java, Java 8
  • Agility
  • Testing: Geb, Spock, Easyb
  • REST
  • NoSQL: MongoDB, Cassandra
  • Hadoop
  • Spring 4
  • Cloud
  • Automation Tools: Gradle, Git, Jenkins, Sonar
  • HTML5, CSS3, AngularJS, jQuery, Usability
  • Mobile Apps - iPhone and Android
  • More...
Learn More »