Project

General

Profile

Actions

Bug #9519

closed

Wrong multiline calculation

Added by Victor (Victor Daev) about 10 years ago. Updated about 10 years ago.

Status:
Rejected
Assignee:
-
Target version:
-
ruby -v:
ruby 2.1.0p0 (2013-12-25 revision 44422) [i686-linux], ruby 2.0.0p353 (2013-11-22 revision 43784) [i686-linux], ruby 1.9.3p484 (2013-11-22 revision 43786) [i686-linux]
[ruby-core:60733]

Description

I have some script with a trouble.

p(100 - (1 + 2 + 3 + 4))

=> 90

ok

p(100 - (1 +
2 +
3 +
4))

=> 90

ok

p(100 - (1

  • 2
  • 3
  • 4))

=> 96

BUT it should be 90

If I run the script I will get

$ rvm use 1.9.3
Using /home/user/.rvm/gems/ruby-1.9.3-p484
$ ruby -v
ruby 1.9.3p484 (2013-11-22 revision 43786) [i686-linux]
$ ruby wrong_multiline_calculation.rb
90
90
96

$ rvm use 2.0.0
Using /home/user/.rvm/gems/ruby-2.0.0-p353
$ ruby -v
ruby 2.0.0p353 (2013-11-22 revision 43784) [i686-linux]
$ ruby wrong_multiline_calculation.rb
90
90
96

$ rvm use 2.1
Using /home/user/.rvm/gems/ruby-2.1.0
$ ruby -v
ruby 2.1.0p0 (2013-12-25 revision 44422) [i686-linux]
$ ruby wrong_multiline_calculation.rb
90
90
96


Files

wrong_multiline_calculation.rb (138 Bytes) wrong_multiline_calculation.rb Victor (Victor Daev), 02/14/2014 10:04 AM

Updated by Victor (Victor Daev) about 10 years ago

Ooops. How can I fix the layout?

Updated by Victor (Victor Daev) about 10 years ago

p(100 - (1 + 2 + 3 + 4))
# => 90
# ok

p(100 - (1 +
2 +
3 +
4))
# => 90
# ok

p(100 - (1
+ 2
+ 3
+ 4))
# => 96
# BUT it should be 90

Updated by phasis68 (Heesob Park) about 10 years ago

I think this issue is not a bug.

p(100 - (1

  • 2
  • 3
  • 4))

is interpreted as

p(100-(1;+2;+3;+4))

Updated by Victor (Victor Daev) about 10 years ago

Heesob Park wrote:

I think this issue is not a bug.
p(100 - (1

  • 2
  • 3
  • 4))
    is interpreted as
    p(100-(1;+2;+3;+4))

Is it ok? How about "the Principle of Least Surprise"?

Updated by nobu (Nobuyoshi Nakada) about 10 years ago

  • Status changed from Open to Rejected

PoLS is not for Ruby.

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0