# Bug in String#rjust

**URL:** <https://rubytalk.org/t/bug-in-string-rjust/15395>\
**Category:** ruby-talk\
**Created:** [20 December 2004 13:05 UTC](https://rubytalk.org/t/bug-in-string-rjust/15395 "2004-12-20T13:05:06Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Matt\_Mower](https://avatars.discourse-cdn.com/v4/letter/m/fbc32d/32.png) [@Matt\_Mower](https://rubytalk.org/u/Matt_Mower)\
**Post date:** [20 December 2004 13:05 UTC](https://rubytalk.org/t/bug-in-string-rjust/15395/1 "2004-12-20T13:05:06Z")

</div>

Hi.

I'm using one-click-installer Ruby 1.8.2 (2004-11-06) on WinXP-SP1 and  
I think I have a bug in the String method #rjust

irb(main):002:0\> "0".rjust( 2, "-" )  
=\> " 0"  
irb(main):003:0\> "0".rjust( 2, "-", 22 )  
ArgumentError: wrong number of arguments (3 for 2)  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;from (irb):3:in `rjust'  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;from (irb):3  
irb(main):004:0\>

It's expecting 2 parameters, but ignoring the padding argument and using spaces.

Does anyone else see this?

M

> **···**
>
> --  
> Matt Mower :: [http://matt.blogs.it/](http://matt.blogs.it/)

---

<div class="post-metadata">

**Author:** ![Ardanwen](https://avatars.discourse-cdn.com/v4/letter/a/67e7ee/32.png) [@Ardanwen](https://rubytalk.org/u/Ardanwen)\
**Post date:** [20 December 2004 13:17 UTC](https://rubytalk.org/t/bug-in-string-rjust/15395/2 "2004-12-20T13:17:05Z")

</div>

Matt Mower wrote:

> Hi.
> 
> I'm using one-click-installer Ruby 1.8.2 (2004-11-06) on WinXP-SP1

and

> I think I have a bug in the String method #rjust
> 
> irb(main):002:0\> "0".rjust( 2, "-" )  
> =\> " 0"  
> irb(main):003:0\> "0".rjust( 2, "-", 22 )  
> ArgumentError: wrong number of arguments (3 for 2)  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;from (irb):3:in `rjust'  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;from (irb):3  
> irb(main):004:0\>
> 
> It's expecting 2 parameters, but ignoring the padding argument and

using spaces.

> Does anyone else see this?
> 
> M
> 
> --  
> Matt Mower :: [http://matt.blogs.it/](http://matt.blogs.it/)

> boris:falcon:~:irb  
> irb(main):001:0\> "0".rjust( 2, "-")  
> ArgumentError: wrong # of arguments(2 for 1)  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;from (irb):1:in `rjust'  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;from (irb):1  
> irb(main):002:0\> "0".rjust( 2, "-", 22 )  
> ArgumentError: wrong # of arguments(3 for 1)  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;from (irb):2:in `rjust'  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;from (irb):2  
> irb(main):003:0\>

Linux. Seeing something else.

---

<div class="post-metadata">

**Author:** ![Kaspar\_Schiess](https://avatars.discourse-cdn.com/v4/letter/k/d78d45/32.png) [@Kaspar\_Schiess](https://rubytalk.org/u/Kaspar_Schiess)\
**Post date:** [21 December 2004 00:23 UTC](https://rubytalk.org/t/bug-in-string-rjust/15395/3 "2004-12-21T00:23:03Z")

</div>

Matt Mower \<matt.mower@gmail.com\> wrote in news:d5637319041220050544f98a42  
@mail.gmail.com:

> Does anyone else see this?

Nope.  
ruby 1.8.1 (2003-12-25) [i386-mingw32]

kaspar

hand manufactured code - www.tua.ch/ruby

---

<div class="post-metadata">

**Author:** ![Roland\_Schmit](https://avatars.discourse-cdn.com/v4/letter/r/ecb155/32.png) [@Roland\_Schmit](https://rubytalk.org/u/Roland_Schmit)\
**Post date:** [20 December 2004 13:20 UTC](https://rubytalk.org/t/bug-in-string-rjust/15395/4 "2004-12-20T13:20:57Z")

</div>

Ardanwen schrieb:

> Matt Mower wrote:
> 
> > Hi.
> > 
> > I'm using one-click-installer Ruby 1.8.2 (2004-11-06) on WinXP-SP1
> 
> and
> 
> > I think I have a bug in the String method #rjust
> > 
> > irb(main):002:0\> "0".rjust( 2, "-" )  
> > =\> " 0"  
> > irb(main):003:0\> "0".rjust( 2, "-", 22 )  
> > ArgumentError: wrong number of arguments (3 for 2)  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;from (irb):3:in `rjust'  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;from (irb):3  
> > irb(main):004:0\>
> > 
> > It's expecting 2 parameters, but ignoring the padding argument and
> 
> using spaces.
> 
> > Does anyone else see this?
> > 
> > M
> > 
> > --  
> > Matt Mower :: [http://matt.blogs.it/](http://matt.blogs.it/)
> 
> \>boris:falcon:~:irb  
> \>irb(main):001:0\> "0".rjust( 2, "-")  
> \>ArgumentError: wrong # of arguments(2 for 1)  
> \> from (irb):1:in `rjust'  
> \> from (irb):1  
> \>irb(main):002:0\> "0".rjust( 2, "-", 22 )  
> \>ArgumentError: wrong # of arguments(3 for 1)  
> \> from (irb):2:in `rjust'  
> \> from (irb):2  
> \>irb(main):003:0\>
> 
> Linux. Seeing something else.

Microsoft Windows XP [Version 5.1.2600]  
(C) Copyright 1985-2001 Microsoft Corp.

c:\\>ruby -v  
ruby 1.9.0 (2004-11-08) [i386-mswin32]

c:\\>irb  
irb(main):001:0\> "0".rjust(2,"-")  
=\> "-0"  
irb(main):002:0\> quit

c:\\>set path=c:\ruby182\bin;%PATH%

c:\\>ruby -v  
ruby 1.8.2 (2004-11-06) [i386-mswin32]

c:\\>irb  
irb(main):001:0\> "0".rjust(2,"-")  
=\> " 0"  
irb(main):002:0\>

Regards,  
Roland

---

<div class="post-metadata">

**Author:** ![Robert](https://avatars.discourse-cdn.com/v4/letter/r/e95f7d/32.png) [@Robert](https://rubytalk.org/u/Robert)\
**Post date:** [20 December 2004 13:22 UTC](https://rubytalk.org/t/bug-in-string-rjust/15395/5 "2004-12-20T13:22:40Z")

</div>

"Ardanwen" \<bvschmid@gmail.com\> schrieb im Newsbeitrag  
news:1103548501.911640.40570@f14g2000cwb.googlegroups.com...

> Matt Mower wrote:  
> \> Hi.  
> \>  
> \> I'm using one-click-installer Ruby 1.8.2 (2004-11-06) on WinXP-SP1  
> and  
> \> I think I have a bug in the String method #rjust  
> \>  
> \> irb(main):002:0\> "0".rjust( 2, "-" )  
> \> =\> " 0"  
> \> irb(main):003:0\> "0".rjust( 2, "-", 22 )  
> \> ArgumentError: wrong number of arguments (3 for 2)  
> \> from (irb):3:in `rjust'  
> \> from (irb):3  
> \> irb(main):004:0\>  
> \>  
> \> It's expecting 2 parameters, but ignoring the padding argument and  
> using spaces.  
> \>  
> \> Does anyone else see this?  
> \>  
> \> M  
> \>  
> \> --  
> \> Matt Mower :: [http://matt.blogs.it/](http://matt.blogs.it/)
> 
> \>boris:falcon:~:irb  
> \>irb(main):001:0\> "0".rjust( 2, "-")  
> \>ArgumentError: wrong # of arguments(2 for 1)  
> \> from (irb):1:in `rjust'  
> \> from (irb):1  
> \>irb(main):002:0\> "0".rjust( 2, "-", 22 )  
> \>ArgumentError: wrong # of arguments(3 for 1)  
> \> from (irb):2:in `rjust'  
> \> from (irb):2  
> \>irb(main):003:0\>
> 
> Linux. Seeing something else.

Works for me:

13:56:07 [source]: irbs

> > "0".rjust( 2 )

=\> " 0"

> > "0".rjust( 2, "-")

=\> "-0"

> > RUBY\_VERSION

=\> "1.8.1"

> > exit

14:17:53 [source]: uname -a  
CYGWIN\_NT-5.0 bond 1.5.12(0.116/4/2) 2004-11-10 08:34 i686 unknown unknown  
Cygwin

Kind regards

&nbsp;&nbsp;&nbsp;&nbsp;robert

---

<div class="post-metadata">

**Author:** ![Nikolai\_Weibull](https://avatars.discourse-cdn.com/v4/letter/n/ce7236/32.png) [@Nikolai\_Weibull](https://rubytalk.org/u/Nikolai_Weibull)\
**Post date:** [20 December 2004 13:30 UTC](https://rubytalk.org/t/bug-in-string-rjust/15395/6 "2004-12-20T13:30:29Z")

</div>

\* Ardanwen \<bvschmid@gmail.com\> [Dec 20, 2004 14:20]:

[rjust bug]

> Linux. Seeing something else.

It's fixed in CVS,  
&nbsp;&nbsp;nikolai

> **···**
>
> --  
> ::: name: Nikolai Weibull :: aliases: pcp / lone-star / aka :::  
> ::: born: Chicago, IL USA :: loc atm: Gothenburg, Sweden :::  
> ::: page: [www.pcppopper.org](http://www.pcppopper.org) :: fun atm: gf,lps,ruby,lisp,war3 :::  
> main(){printf(&linux["\021%six\012\0"],(linux)["have"]+"fun"-97);}
