promote_rule

promote_rule(type1, type2)

Specifies what type should be used by promote when given values of types type1 and type2. This function should not be called directly, but should have definitions added to it for new types as appropriate.

Examples

julia> promote_rule(Int64, Float64)
Float64

In the Julia programming language, the promote_rule function is used to specify what type should be used by promote when given values of types type1 and type2. It is important to note that promote_rule should not be called directly, but rather definitions should be added to it for new types as appropriate.

Here is an example of using promote_rule to determine the resulting type when promoting Int64 and Float64. In this case, the resulting type is Float64. This means that if you were to perform an operation between an Int64 and a Float64, the resulting type would be Float64.

You can define your own promote rules for custom types as needed, allowing you to control the type promotion behavior for those types.

See Also

User Contributed Notes

Add a Note

The format of note supported is markdown, use triple backtick to start and end a code block.

*Required Field
Details

Checking you are not a robot: