I have two rather simple class methods coded in Ruby...my own each
iterator: The iterator is used internally within the class/namespace,
and be available externally. That way I can keep everything hidden
about the "instructions table."
# Loop through each instruction in the block, yielding the result from
# the specified code block.
def each(&logic)
@instructions.each {|instr| yield instr}
end
# Find the specified instruction parm (string) in the block. Returns
# nil if parm not found.
def find(p)
self.each {|i| return i if i.parm.index(p) }
nil
end
I'm trying to recode this exact functionality in C#, and am just not
getting the Delegate stuff. Can you direct me to some online examples
or references that show how to pass a delegate into method that
implements an iterator? I'm just not getting all the new C#
terminology and syntax complexities, and I need to learn it. MSDN
isn't helping me at all. The following is quasi psuedo mock up of
what I'm trying to accomplish.
public void each(Delegate block)
{
foreach (FL_Instruction i in this.Instructions)
{
block;
}
}
public static FL_Instruction find(string parm)
{
this.each( delegate(FL_Instruction i) { if
(i.Parm.IndexOf(parm) 0) { return i; } };);
return null;
}
Thanks for your time and consideration. Once I can get that "Ah
Haaa...now I got it" feeling, I'll be good to go for the future.
dvn