我在Scala中创建了一个自定义类,如下所示:
class DQOpsStoreProfileStatusS extends Serializable{
final val serialVersionUID = 1l
private var _id:Int = _
private var _runStatusId:Int = _
private var _lakeHdfsPath:String = _
def id = this._id
def id_ = (_id:Int) = this._id = _id
def runStatusId = this._runStatusId
def runStatusId_ = (_runStatusId:Int) = this._runStatusId = _runStatusId
def lakeHdfsPath = this._lakeHdfsPath
def lakeHdfsPath_ = (_lakeHdfsPath:String) = this._lakeHdfsPath = _lakeHdfsPath
}
我在另一个看起来像这样的对象中引用了这个类:
var colResult = new DQOpsStoreProfileStatusS
colResult.fieldIndex = curIndex
colResult.lakeHdfsPath = inputFileLocation
我的两个二传手在抱怨"重新分配给瓦尔"。我看了一堆例子,不明白我做错了什么?
setter的方法名应以_=
结尾,不带空格:def id_=(_id:Int)
等。您定义的方法不带参数,称为id_
、runStatusId_
和lakeHdfsPath_
。