问题
I program in Java, C and Python.
The rule for automatic coercions among arithmetic types have been augmented to handle the richer set of types
Source: "The C Programming Language"
But what does "coercion" mean? The answers say it's like type conversion and implicit casts and implicit type conversions and called autoboxing where I read it. So what is the difference between automboxing and coercion?
Thanks
回答1:
Coercion is another name for an implicit type cast, i.e. one mandated by the language rules, and not explicitly added by the programmer.
回答2:
Coercion refers to "type coercion". In other words, you add a variable of type Integer
to a Float
, the Integer
will be coerced to Float
, and the numbers added together.
回答3:
Coercion is the process of changing one data type into another. http://en.wikipedia.org/wiki/Type_conversion
来源:https://stackoverflow.com/questions/11086114/what-is-the-difference-between-autoboxing-and-coercion