Skip to content
Discussion options

You must be logged in to vote

The simplest answer I can give is to compare the context descriptors (because there will only ever be 1 of them per type).

let array = reflectStruct([Int].self)!.descriptor

// Assuming someType refers to some variable containing `TypeMetadata`
guard someType.contextDescriptor.ptr == array.ptr else {
  // The outer type of someType is not an Array
  return nil
}

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@Azoy
Comment options

Azoy May 3, 2021
Maintainer

@NSExceptional
Comment options

Answer selected by NSExceptional
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants