I have values List[Any]and a list of corresponding ClassManifest[_]s types storing values. How can I add some value from the list back to the original type?
List[Any]
ClassManifest[_]
def cast[T](x: Any, mf: ClassManifest[T]): T = x.asInstanceOf[T] does not work.
def cast[T](x: Any, mf: ClassManifest[T]): T = x.asInstanceOf[T]
Thank you for your responses.
This can never work, since the return type castwill always be considered the highest general supertype of any T. At compile time, this cannot be made more specific.
cast
T
If you are trying to create a strongly typed collection of disparate types, then what you really want is an HList:
http://jnordenberg.blogspot.com/2008/09/hlist-in-scala-revisited-or-scala.html
Class Java/Scala - Class.cast. , :
Class
Class.cast
mf.erasure.cast(x) //T
, mf.erasure - Class[_] ( a Class<?> Java), (.. ). () .
mf.erasure
Class[_]
Class<?>
Source: https://habr.com/ru/post/1778928/More articles:GZIP on Android - javaDotnet namespace conventions - namespacesGreek VAT Validation Code - windowshttps://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1778926/jquery-ui-autocomplete-appends-to-body-rather-than-the-given-object-in-jq-ui-version-186&usg=ALkJrhgZ4dT7Djfa4ntrrblqm9L5vrDXbQCreating a .net 1.1 project using msbuild - asp.netHow to transfer char * from C to CPP? - c ++Django-admin clean_fields overrides, saves previous data to send - djangoWPF and NET from 3.5 to 4 multi-targeting - .netПараметры командной строки adobe air - airiphone - простой способ получить это нажатие → удалить эффекты? или move → перемещать эффект просмотра? - iphoneAll Articles