Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

motoko-tutorial/buffers - feedback #14

Open
GeorgeKoller opened this issue Aug 20, 2024 · 0 comments
Open

motoko-tutorial/buffers - feedback #14

GeorgeKoller opened this issue Aug 20, 2024 · 0 comments

Comments

@GeorgeKoller
Copy link

Problem:

I would expect that: cities.content() would return the Text of the cities Buffer.
Fine, it doesn't work, and Motoko is missing consistency.

However, this example fails to give any clue why, or what the work-around is. The error message gave no clue. Searching
the Web did not work for me (where I suspect it would have for most or all mature languages).

Just saying if there are logical exceptions like this, that seem arbitrary, that some clue should be given in the lessons, of course
we are adults, and should not be spoon-fed every response, but perhaps a link to the appropriate documentation, a warning, or
generalization about how to find alternative ways to arrive at text for a buffer.

import D "mo:base/Debug";
import Buffer "mo:base/Buffer";

// Create a buffer named cities with an initial capacity of 3.
let cities = Buffer.Buffer<Text>(3);

cities.add("London");
cities.add("Paris");
cities.add("Toyko");
cities.add("New York");



D.print("buffer size: " # debug_show(cities.size()));
D.print("buffer capacity: " # debug_show(cities.capacity()));
D.print("buffer content: " # debug_show(cities.toArray()));

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant