Oℕ
Size: a a a
Oℕ
NV
Oℕ
Oℕ
AK
GP
AT
GP
AT
AK
AK
AK
GP
AK
V
object Cfg {Как мне для последнего элемента из
def apply(cmd: Commands, dataList: Int*): List[Cfg] = {
List(Cfg(cmd)) ::: dataList.map(Cfg(_)).toList
}
}
// Вызов
// var seq = Cfg(ST7735_FRMCTR1, 0x00, 0x06, 0x03)
dataList
перед добавлением в List
совершить другую операцию? Мне вместо Cfg(_)нужно вызвать другую перегрузку у
apply
.V
object Cfg {Как мне для последнего элемента из
def apply(cmd: Commands, dataList: Int*): List[Cfg] = {
List(Cfg(cmd)) ::: dataList.map(Cfg(_)).toList
}
}
// Вызов
// var seq = Cfg(ST7735_FRMCTR1, 0x00, 0x06, 0x03)
dataList
перед добавлением в List
совершить другую операцию? Мне вместо Cfg(_)нужно вызвать другую перегрузку у
apply
.def apply(cmd: Commands, dataList: Int*): List[Cfg] = {
List(Cfg(cmd)) ::: dataList.map(d => if (d == dataList.last) Cfg(d, CfgLastData, 0) else Cfg(d)).toList
}
Но более красивые варианты приветствуются.IA
def apply(cmd: Commands, dataList: Int*): List[Cfg] = {
List(Cfg(cmd)) ::: dataList.map(d => if (d == dataList.last) Cfg(d, CfgLastData, 0) else Cfg(d)).toList
}
Но более красивые варианты приветствуются.def apply(cmd: Commands, dataList: Int*): List[Cfg] = {
List(Cfg(cmd)) ::: dataList match {
case init :+ last => init.map(Cfg(_)) :+ Cfg(last, CfgLastData, 0)
case Nil => Nil
}
}
попробуй
V
def apply(cmd: Commands, dataList: Int*): List[Cfg] = {
List(Cfg(cmd)) ::: dataList match {
case init :+ last => init.map(Cfg(_)) :+ Cfg(last, CfgLastData, 0)
case Nil => Nil
}
}
попробуй
value ::: is not a member of Int*
[error] List(Cfg(cmd)) ::: dataList match
Если я добавляю toList List(Cfg(cmd)) ::: dataList
.toList match
то другая ошибкаtype mismatch;
[error] found : Any
[error] required: Int
IA
value ::: is not a member of Int*
[error] List(Cfg(cmd)) ::: dataList match
Если я добавляю toList List(Cfg(cmd)) ::: dataList
.toList match
то другая ошибкаtype mismatch;
[error] found : Any
[error] required: Int