The parameters to the methods are only the names for the type it accepts.
say you have a method addNumber(number: T) and when you override the method, you have to follow the same signature but you can give the argument a better name which makes more sense in that context, for example addNumber(integer: Integer).
Take an example of Bag which contains items(item is a generic term here)
trait Bag[T] {
def addToBag(item: T)
def items(): List[T]
}
If the bag contains fruits, you will add fruit to it, so it makes more sense to call the input argument as fruit: Fruit but its up to you to call it whatever you want.
case class Fruit(name: String)
trait FruitBag extends Bag[Fruit]
class MyFruitBag extends FruitBag {
var list = scala.collection.mutable.ListBuffer[Fruit]()
override def addToBag(fruit: Fruit): Unit = {
println("adding item")
list.+=:(fruit)
}
override def items(): List[Fruit] = list.toList
}
If the bag contains Toys, you will want to call the input argument as toy which is more contextual but again you can give it whatever name you want.
case class Toy(name: String)
trait ToyBag extends Bag[Toy]
class MyToysBag extends ToyBag {
var list = scala.collection.mutable.ListBuffer[Toy]()
override def addToBag(toy: Toy): Unit = {
println("adding item")
list.+=:(toy)
}
override def items(): List[Toy] = list.toList
}
Summary is when you override methods you override the signature only, not necessarily the exact names of the arguments, arguments are named based on the context of the child class.