Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> While most programming languages allow you to take an expression (1213, "moo") and infer the type (Int, String), Scala allows you to go the other direction: take the type (Int, String) and infer a value (1213, "moo")! This is tremendously useful in a whole range of different scenarios

That's an interesting way to put it (and pretty neat), but I guess I'm not totally convinced it is that useful in practice. I saw the linked example about the parser using implicit objects but I think that could be rewritten in a number of different ways without relying on that feature.



It is for example very usefull to generate random test data (property based testing) in a very elegant way, without manually wiring up a lot of stuff.


DI in Java world is another example where people require this type of feature (unsafely) via reflection.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: