Skip to content

Conversation

nevkontakte
Copy link
Member

Instead of being initialized at the package level, they are initialized inside a generic factory, where type params are available.

Example:

// Go:
func _F[T any](t T) {
  _ = []T{}
}

// JS:
_F = function(T){
  var sliceType = $sliceType(T);
  return function(t) {
    $unused(new sliceType([]));
  };
};

Updates #1013.

@nevkontakte nevkontakte requested a review from flimzy October 24, 2022 12:20
@nevkontakte
Copy link
Member Author

/cc @paralin

Copy link
Contributor

@paralin paralin left a comment

Choose a reason for hiding this comment

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

LGTM! Thanks as always @nevkontakte :)

Instead of being initialized at the package level, they are initialized
inside a generic factory, where type params are available.

Example:

```
// Go:
func _F[T any](t T) {
  _ = []T{}
}

// JS:
_F = function(T){
  var sliceType = $sliceType(T);
  return function(t) {
    $unused(new sliceType([]));
  };
};
```
@nevkontakte nevkontakte merged commit fe3f70e into gopherjs:generics Oct 27, 2022
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

Successfully merging this pull request may close these issues.

3 participants