Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
RubyManiaConsoleProject - Demo to show the Ruby Integer times method in Delphi and C#
using System;
public static class IntExtensions
{
public static void Times(this int i, Action<int> func)
{
for(int j = 0; j < i; j++)
{
func(j);
}
}
}
public class Program
{
public static void Main()
{
5.Times(i => Console.Write("{0} ", i));
}
}
program RubyManiaConsoleProject;
uses
System.SysUtils;
type
TRubyMania = record helper for ShortInt
procedure times(const IterBody: TProc<Integer>);
end;
procedure TRubyMania.times(const IterBody: TProc<Integer>);
var
i: Integer;
begin
for i := 0 to Self-1 do
IterBody(i);
end;
begin
5.times(
procedure(i: Integer)
begin
Write(i, ' ');
end
);
end.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.