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

[Docs] use self.cap in heap allocated array example #4126

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions mojo/docs/manual/functions.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -368,8 +368,13 @@ def greet(*names: String):
Inside the function body, the variadic argument is available as an iterable list
for ease of use. Currently there are some differences in handling the list
depending on whether the arguments are register-passable types (such as `Int`)
or memory-only types (such as `String`). TODO: We hope to remove these
differences in the future.
or memory-only types (such as `String`).

:::note TODO

We hope to remove these differences in the future.

:::

Register-passable types, such as `Int`, are available as a
[`VariadicList`](/mojo/stdlib/builtin/list_literal/VariadicList) type. As
Expand Down
4 changes: 2 additions & 2 deletions mojo/docs/manual/lifecycle/life.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ can happen when one of the following occurs:
- You return a value of one type from a function that specifies a different
return type.

In both cases, implicit conversion is supported when the target type
In all cases, implicit conversion is supported when the target type
defines a constructor that meets the following criteria:

- Is declared with the `@implicit` decorator.
Expand Down Expand Up @@ -451,7 +451,7 @@ struct HeapArray:
fn __init__(out self, size: Int, val: Int):
self.size = size
self.cap = size * 2
self.data = UnsafePointer[Int].alloc(self.size)
self.data = UnsafePointer[Int].alloc(self.cap)
for i in range(self.size):
(self.data + i).init_pointee_copy(val)
Expand Down