Skip to content

Annoying to have to write double literals for integer values. #3

Closed
@lrhn

Description

@lrhn

In Dart, unlike many other languages, integers and doubles are objects, not "primitive values". There are no special rules converting between the types on assignment (assignment generally preserves the identity of objects).

This can be annoying when you want to write something simple, like:

double x = 10;
foo(double x) => ...;
foo(42);

Here the integer number isn't allowed where a double is expected, so the program fails to compile. You have to write it as 10.0 and 42.0 to get the program compiling. This is annoying, and it feels like needless overhead when the meaning is clear.

I would be nice if you didn't have to write the extra .0, the compiler should be able to figure that out.

Proposed solutions: #4

Metadata

Metadata

Assignees

No one assigned

    Labels

    requestRequests to resolve a particular developer problem

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions