Please help me translate C# code to Ruby

Posted by Valentin Vasilyev on Stack Overflow See other posts from Stack Overflow or by Valentin Vasilyev
Published on 2010-04-21T07:32:05Z Indexed on 2010/04/21 7:33 UTC
Read the original article Hit count: 249

Filed under:
|
|
|

Here is the code:

using System;
using System.Collections.Generic;
using System.Linq;


namespace cs2 {
    class Program {
        static void Main(string[] args) {          
          var i=Fibs.TakeWhile(x=>x < 1000).Where(x=>x % 2==0).Sum();
        }

        static IEnumerable<long> Fibs() {
            long a = 0, b = 1;
            while (true) {
                yield return b;
                b += a;
                a = b - a;
            }
        }
    }
}

© Stack Overflow or respective owner

Related posts about c#

Related posts about LINQ