Discussion:
[dart-misc] Is this a bug? Dart 1.20 Dev 10.1
Steve Lympany
2016-10-13 15:23:42 UTC
Permalink
main() {
List SL=''.split('_');
int len=SL.length;
print("SL= $SL");

print("Length = $len");


outputs :

SL= []

Length = 1


The length should be zero.

cheers
Steve
--
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+***@dartlang.org.
Frank Pepermans
2016-10-13 15:29:46 UTC
Permalink
Nope, it's just a list with one element, an empty String?

Try 'a'.split('_');
Post by Steve Lympany
main() {
List SL=''.split('_');
int len=SL.length;
print("SL= $SL");
print("Length = $len");
SL= []
Length = 1
The length should be zero.
cheers
Steve
--
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
--
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+***@dartlang.org.
'Bob Nystrom' via Dart Misc
2016-10-13 15:30:35 UTC
Permalink
Post by Steve Lympany
main() {
List SL=''.split('_');
int len=SL.length;
print("SL= $SL");
print("Length = $len");
From the docs
<https://api.dartlang.org/stable/1.20.1/dart-core/String/split.html>:

If this string is empty, the result is an empty list if pattern matches the
Post by Steve Lympany
empty string, and it is [""] if the pattern doesn't match.
Cheers!

– bob
--
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+***@dartlang.org.
s***@gmail.com
2016-10-13 15:55:21 UTC
Permalink
Hi,

Ah. Thanks. It's the print that confused me :

List pp=[''];
print (pp)

Outputs

[], with no quotes.

An empty list prints identically. 😐

Cheers
Steve


-----Original Message-----
From: 'Bob Nystrom' via Dart Misc <***@dartlang.org>
To: General Dart Discussion <***@dartlang.org>
Sent: Thu, 13 Oct 2016 16:31
Subject: Re: [dart-misc] Is this a bug? Dart 1.20 Dev 10.1
Post by Steve Lympany
main() {
List SL=''.split('_');
int len=SL.length;
print("SL= $SL");
print("Length = $len");
From the docs
<https://api.dartlang.org/stable/1.20.1/dart-core/String/split.html>:

If this string is empty, the result is an empty list if pattern matches the
Post by Steve Lympany
empty string, and it is [""] if the pattern doesn't match.
Cheers!

– bob
--
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+***@dartlang.org.
--
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+***@dartlang.org.
'Samuel Rawlins' via Dart Misc
2016-10-13 15:31:35 UTC
Permalink
You almost took an example straight out of the split() documentation:

https://api.dartlang.org/stable/1.20.1/dart-core/String/split.html

var string = '';
string.split(''); // []
string.split("a"); // ['']

https://dartpad.dartlang.org/89fd3e44873773d9b1a1691a002886b3
Post by Steve Lympany
main() {
List SL=''.split('_');
int len=SL.length;
print("SL= $SL");
print("Length = $len");
SL= []
Length = 1
The length should be zero.
cheers
Steve
--
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
--
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+***@dartlang.org.
s***@gmail.com
2016-10-13 15:42:33 UTC
Permalink
Ah! Didn't see it.

Sorry for wasting anyone's time!

Cheers
Steve
07771 960 074

-----Original Message-----
From: 'Samuel Rawlins' via Dart Misc <***@dartlang.org>
To: General Dart Discussion <***@dartlang.org>
Sent: Thu, 13 Oct 2016 16:31
Subject: Re: [dart-misc] Is this a bug? Dart 1.20 Dev 10.1

You almost took an example straight out of the split() documentation:

https://api.dartlang.org/stable/1.20.1/dart-core/String/split.html

var string = '';
string.split(''); // []
string.split("a"); // ['']

https://dartpad.dartlang.org/89fd3e44873773d9b1a1691a002886b3
Post by Steve Lympany
main() {
List SL=''.split('_');
int len=SL.length;
print("SL= $SL");
print("Length = $len");
SL= []
Length = 1
The length should be zero.
cheers
Steve
--
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
--
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+***@dartlang.org.
--
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+***@dartlang.org.
Continue reading on narkive:
Loading...