Project

General

Profile

Actions

Bug #12569

closed

There is no any warnings or errors with wrong comma after last attr_accessor attribute

Added by [email protected] (Roman Krasavtsev) almost 9 years ago. Updated almost 9 years ago.

Status:
Rejected
Assignee:
-
Target version:
-
ruby -v:
ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-darwin15]
[ruby-core:76303]

Description

In second sample we don't have any warnings or errors with wrong comma after last attr_accessor attribute and without it is very difficult to identify the typo. initialize method does not performed.

It works

class Solution
  attr_accessor :one, :two, :three

  def initialize
    @one = @two = @three = []
    puts "Done!"
  end
end

solution = Solution.new
p solution.one
p solution.two
p solution.three

Result:

MacBook-Air-Roman% ruby ruby_solution.rb
Done!
[]
[]
[]

it does not work

class Solution
  attr_accessor :one, :two, :three,

  def initialize
    @one = @two = @three = []
    puts "Done!"
  end
end

solution = Solution.new
p solution.one
p solution.two
p solution.three

Result

MacBook-Air-Roman% ruby ruby_solution.rb
nil
nil
nil

Updated by nobu (Nobuyoshi Nakada) almost 9 years ago

  • Description updated (diff)
  • Status changed from Open to Closed

Try with -w option.

Updated by usa (Usaku NAKAMURA) almost 9 years ago

  • Status changed from Closed to Rejected
Actions

Also available in: Atom PDF

Like0
Like0Like0