Skip to content

Default Value of Class Attributes

Andrias Meisyal edited this page Aug 29, 2019 · 2 revisions

Let's say, a class attribute has a default value as presented on the picture below.

Default value of class attributes

An attribute name has a default value of "John". You can set the default value on the properties pane of StarUML. The pane will appear on right side when you click an attribute of class.

If you generate Author class above, this extension will generate:

author.rb

class Author
  def initialize(name='John', email)
    @name = name
    @email = email
  end

  private
    attr_accessor :name, :email

  def to_s
    "Your string representation of the object will be written here."
  end
end

Note that the example above uses default configuration of the extension.

Clone this wiki locally