3 Replies Latest reply on Dec 14, 2007 12:04 AM by chronodm

    const & constructors: stupid question

    chronodm
      I understood that a const member can be assigned either in the declaration or in the class constructor, but when I try it (FlexBuilder 3 beta 2) it doesn't compile.

      Can anyone tell me what I'm doing wrong?

      package foo
      {
      public class Bar
      {
      //------------------------------------------------------------
      // Immutable instance variables

      private const _name:String;

      //------------------------------------------------------------
      // Constructor

      public function Bar(name:String)
      {
      _name = name; // <-- "Illegal assignment"
      }

      //------------------------------------------------------------
      // Accessors

      public function get name():String
      {
      return _name;
      }
      }
      }