Conversions in Dart

70 views
Skip to first unread message

Raquel Moreno

unread,
Sep 12, 2016, 11:10:40 PM9/12/16
to Dart Misc
What's up guys?  I need your help.

I know that Dart  is dynamically typed and all that stuff, but I'm wondering about how Dart works with narrowing conversion and widening conversion. Or it simply doesn't work with it? I read a lot of links on the internet and I dont conclude anything. Someone could light up my mind about it?

Thanks

Erik Ernst

unread,
Sep 13, 2016, 3:43:43 AM9/13/16
to Dart Misc
On Tue, Sep 13, 2016 at 5:10 AM, Raquel Moreno <raque...@gmail.com> wrote:
What's up guys?  I need your help.

I know that Dart  is dynamically typed and all that stuff, but I'm wondering about how Dart works with narrowing conversion and widening conversion. Or it simply doesn't work with it? I read a lot of links on the internet and I dont conclude anything. Someone could light up my mind about it?

The basic coercion mechanism is available as methods on the built-in classes. For instance, `print(3.14.toInt())` prints "3". Check out pages like https://api.dartlang.org/stable/dart-core/double-class.html for related methods like `ceil`, `floor`, and `truncate`.

Thanks

--
For other discussions, see https://groups.google.com/a/dartlang.org/
 
For HOWTO questions, visit http://stackoverflow.com/tags/dart
 
To file a bug report or feature request, go to http://www.dartbug.com/new
---
You received this message because you are subscribed to the Google Groups "Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send an email to misc+uns...@dartlang.org.



--
Erik Ernst  -  Google Danmark ApS
Skt Petri Passage 5, 2 sal, 1165 København K, Denmark
CVR no. 28866984

Lasse R.H. Nielsen

unread,
Sep 13, 2016, 3:44:12 AM9/13/16
to mi...@dartlang.org
On Tue, Sep 13, 2016 at 5:10 AM, Raquel Moreno <raque...@gmail.com> wrote:
What's up guys?  I need your help.

I know that Dart  is dynamically typed and all that stuff, but I'm wondering about how Dart works with narrowing conversion and widening conversion.

Dart has no automatic conversions, neither narrowing, widening, or otherwise.
 
Or it simply doesn't work with it? I read a lot of links on the internet and I dont conclude anything. Someone could light up my mind about it?

Since Dart only has one integer type, a "bigint" that  supports arbitrary magnitude numbers, there is no need for narrowing or widening, nor is there any type to narrow or widen to.

In Dart 2 that may change if it introduces fixed-sized integers.

/L
--
Lasse R.H. Nielsen - l...@google.com  
'Faith without judgement merely degrades the spirit divine'
Google Denmark ApS - Frederiksborggade 20B, 1 sal - 1360 København K - Denmark - CVR nr. 28 86 69 84
Reply all
Reply to author
Forward
0 new messages