Project

General

Profile

Actions

Feature #16644

closed

qualified const init (self::CONST1 = 1) should be allowed in methods

Added by bughit (bug hit) about 4 years ago. Updated about 4 years ago.

Status:
Rejected
Assignee:
-
Target version:
-
[ruby-core:97220]

Description

module Mod1
  def self.define_consts
    const_set(:CONST1, :CONST1)

    # this is actual const re-assignment but only a warning
    const_set(:CONST1, :CONST1)
    
    
    # this is const initialization but becomes an error
    # because it looks like it could be re-assignment
    # if actual const re-assignment is only a warning
    # why is a possible const re-assignment (which might not be one), an error
    self::CONST2 = :CONST2 unless const_defined?(:CONST2, false)
    
  end
  
  define_consts
end
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0