8000 Fix #1115: Enrich js.WrappedArray with Buffer and BufferLike. by sjrd · Pull Request #1119 · scala-js/scala-js · GitHub
[go: up one dir, main page]

Skip to content

Fix #1115: Enrich js.WrappedArray with Buffer and BufferLike. #1119

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

Merged
merged 5 commits into from
Sep 26, 2014
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Add a setter for js.Array.length.
  • Loading branch information
sjrd committed Sep 26, 2014
commit 2d4058a14ce01a74fde6dd4f5fcf4ee18e3310ab
7 changes: 7 additions & 0 deletions library/src/main/scala/scala/scalajs/js/Array.scala
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,13 @@ class Array[A] extends Object {
/** Length of the array. */
def length: Int = native

/** Sets the length of the array.
* If the new length is bigger than the old length, created slots are
* filled with `undefined` (irrespective of the type argument `A`!).
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't like this, but I guess there is nothing we can do... Having js.Array.apply(x: Int) return js.UndefOr is too harsh...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We already the problem with new js.Array[A](n) anyway.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True

* If the new length is smaller than the old length, the array is shrunk.
*/
def length_=(v: Int): Unit = native

/** Access the element at the given index. */
@JSBracketAccess
def apply(index: Int): A = native
Expand Down
0