Increment/decrement

what is Ruby's style of increment/decrement?

I mean like in C++

someVar++
or someVar--

···

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

what is Ruby's style of increment/decrement?

I mean like in C++

someVar++
or someVar--

someVar += 1

Or, more likely, work out why you don't really need to increment and
use something else (hint, if you're incrementing an array index,
you're probably doing it wrong)

···

On Fri, Dec 4, 2009 at 12:22 PM, Teodor Carstea <teodorcarstea@yahoo.com> wrote:

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

--
Paul Smith
http://www.nomadicfun.co.uk

paul@pollyandpaul.co.uk

Take a look at Ruby-Doc.org: Documenting the Ruby Language which includes "To increment a number, simply write x += 1T."

Hope this helps,

Mike

···

On Dec 4, 2009, at 7:22 AM, Teodor Carstea wrote:

what is Ruby's style of increment/decrement?

I mean like in C++

someVar++
or someVar--

--

Mike Stok <mike@stok.ca>
http://www.stok.ca/~mike/

The "`Stok' disclaimers" apply.

Teodor, if you now start wondering why there is no i++ in Ruby please
see the recent thread "Ruby doesn't implement x++ for Fixnum's because
???".

http://groups.google.de/group/comp.lang.ruby/browse_frm/thread/c07525fb34aacd18/b83161b23e9e57d1?lnk=gst&q=increment#b83161b23e9e57d1

Cheers

robert

···

2009/12/4 Mike Stok <mike@stok.ca>:

On Dec 4, 2009, at 7:22 AM, Teodor Carstea wrote:

what is Ruby's style of increment/decrement?

I mean like in C++

someVar++
or someVar--

Take a look at Ruby-Doc.org: Documenting the Ruby Language which includes "To increment a number, simply write x += 1T."

--
remember.guy do |as, often| as.you_can - without end
http://blog.rubybestpractices.com/

Hi,

> what is Ruby's style of increment/decrement?
>
> I mean like in C++
>
> someVar++
> or someVar--

someVar += 1

You may also say

  someVar = someVar.succ

With strings even this works:

  str = "A0000"
  str.succ!

For iterating use somethig like Fixnum#times or Array#each.

Bertram

···

Am Freitag, 04. Dez 2009, 21:34:31 +0900 schrieb Paul Smith:

On Fri, Dec 4, 2009 at 12:22 PM, Teodor Carstea <teodorcarstea@yahoo.com> wrote:

--
Bertram Scharpf
Stuttgart, Deutschland/Germany
http://www.bertram-scharpf.de