2

How do I append a single element to a list in Ceylon? I tried the append method like this, but it only accepts another list:

value list = [1,2].append(3); // Integer is not assignable to 'Nothing[]'

Obviously, I can work around by wrapping the element:

value list = [1,2].append([3]);

But I feel there should be a better way...

drhagen
  • 8,331
  • 8
  • 53
  • 82

1 Answers1

4

You must be a Python programmer. The method you are looking for is called withTrailing:

value list = [1,2].withTrailing(3);
drhagen
  • 8,331
  • 8
  • 53
  • 82