On Sat, Mar 6, 2010 at 2:58 PM, Kalinkin Kirill
<kirill.superski / gmail.com> wrote:
> I have to translate code from ruby to .net
> And I dont understand what means << in the code. Its simple I know but
> please do not delete question and answer the question please
>
> def eval_op(op, val1, val2, expr1, expr2, source, source_expr)
> =A0result =3D val1.send(op, val2)
> =A0expr =3D "(#{expr1} #{op} #{expr2})"
> =A0test(result, expr)
> =A0source << result; source_expr << expr
> =A0find(source, source_expr)
> =A0source.pop; source_expr.pop
> end
>
> Thanks in advance!

It depends on what objects source and source_expr are.

<< is just a message, and different objects can implement it differently.

For integers << x means shift left x bits,

For arrays << x means append x to the end of the array.

Most classes will implement << with something like one of these two
meanings in mind.

There's no way to tell from that snippet of code whether source and
source_expr are instances of standard Ruby classes or classes written
as part of the overall application.


--=20
Rick DeNatale

Blog: http://talklikeaduck.denhaven2.com/
Twitter: http://twitter.com/RickDeNatale
WWR: http://www.workingwithrails.com/person/9021-rick-denatale
LinkedIn: http://www.linkedin.com/in/rickdenatale