Ruby-style "each" in D?

Vladimir Panteleev vladimir at thecybershadow.net
Sun Mar 23 10:33:02 PDT 2014


On Friday, 21 March 2014 at 13:33:21 UTC, Dicebot wrote:
> On Friday, 21 March 2014 at 13:27:04 UTC, Vladimir Panteleev 
> wrote:
>> On Friday, 21 March 2014 at 13:24:50 UTC, Dicebot wrote:
>>> On Friday, 21 March 2014 at 12:55:09 UTC, Jacob Carlborg 
>>> wrote:
>>>> What's the purpose of "tee", is it the same as "tap"? "tap" 
>>>> in Ruby just returns the receiver after executing a block. 
>>>> This would be the implementation in D:
>>>
>>> Yeah "tee" is a horrible name, no chance I would have guess 
>>> what it means just by the name. "tap" is much better.
>>
>> I think it's meant to mimic the UNIX command with the same 
>> name? If you know about the command, the function's purpose 
>> seems obvious.
>
> ...and has pretty much nothing in common with it!

Why do you think so?

range
.filter!(s => s.canFind("foo"))
.tee!writeln
...

is equivalent to

cat input         \
  | grep foo       \
  | tee /dev/pts/N \
  | ...


More information about the Digitalmars-d mailing list