Skip to content

Why do we need var? #87

Open
Open
@jxnu-liguobin

Description

@jxnu-liguobin

I am confused with these codes.

What are the requirements for using var and it needs to be public?
Every time I call method getLPAConfig, var changes, so this var is unreliable as "static", why are we doing this?

case class LPAConfig(maxIter: Int, encodeId: Boolean = false)

object LPAConfig {
  var maxIter: Int      = _
  var encodeId: Boolean = false

  def getLPAConfig(configs: Configs): LPAConfig = {
    val lpaConfig = configs.algorithmConfig.map

    maxIter = lpaConfig("algorithm.labelpropagation.maxIter").toInt
    encodeId = ConfigUtil.getOrElseBoolean(lpaConfig, "algorithm.labelpropagation.encodeId", false)
    LPAConfig(maxIter, encodeId)
  }
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    Todo

    Status

    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions