scala - Using toString on case classes to generate a value is a good or bad practice? -


i have case class let's say:

case class offset(a:string, b:int, c: uuid) {  override def tostring: string = productiterator.mkstring(",") }  val offset: string = offset("some_string", 2, java.util.uuid.randomuuid).tostring 

is fine override tostring method on case class or shall implement different method let's generateoffset same thing like:

case class offset(a:string, b:int, c: uuid) {   def generateoffset: string = productiterator.mkstring(",") }  val offset: string = offset("some_string", 2, java.util.uuid.randomuuid).generateoffset 

tostring used people , debugging tools. should contain concise human readable information. should not base logic on tostring

second version more clear, @ least me.


Comments

Popular posts from this blog

php - Permission denied. Laravel linux server -

google bigquery - Delta between query execution time and Java query call to finish -

python - Pandas two dataframes multiplication? -