void foo(int &x) -> Ruby? Passing integers by reference?

Posted by Earlz on Stack Overflow See other posts from Stack Overflow or by Earlz
Published on 2010-04-16T04:35:01Z Indexed on 2010/04/16 4:43 UTC
Read the original article Hit count: 217

Hello, as a way to spice up my C++ programming homework, I've decided to instead of typing the C++ from the book onto my computer, instead reforming it in Ruby. Yes it's a bit silly, but I'm bored.

Anyway, I'm having trouble converting this kind of function to Ruby

void swap(int &a,int &b){
  int c=b;
  b=a;
  a=c
}

What would the equivalent ruby code looking inside a function ?

© Stack Overflow or respective owner

Related posts about ruby

Related posts about translation