Please help. what does mean <<

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)
  result = val1.send(op, val2)
  expr = "(#{expr1} #{op} #{expr2})"
  test(result, expr)
  source << result; source_expr << expr
  find(source, source_expr)
  source.pop; source_expr.pop
end

Thanks in advance!

···

--
Posted via http://www.ruby-forum.com/.

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.

···

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)
result = val1.send(op, val2)
expr = "(#{expr1} #{op} #{expr2})"
test(result, expr)
source << result; source_expr << expr
find(source, source_expr)
source.pop; source_expr.pop
end

Thanks in advance!

--
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

Rick Denatale wrote:

···

On Sat, Mar 6, 2010 at 2:58 PM, Kalinkin Kirill > <kirill.superski@gmail.com> wrote:

�source.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.

It is an array and it means that the operation is push. Thanks a lot for
the quick answer! I became fan of ruby. So elegant language!
--
Posted via http://www.ruby-forum.com/\.