user888379
user888379

Reputation: 1467

Julia - creating NTuple with a single element

I've got a situation where I'm building a struct from NTuples, and it would be convenient if N could equal 1. My experiments in the Julia REPL have not been encouraging. Is there a way of doing this?

Upvotes: 2

Views: 162

Answers (1)

Bogumił Kamiński
Bogumił Kamiński

Reputation: 69839

I am not sure what problem you have exactly, but here is a way to create 1-element tuple and check if this is a NTuple{1}:

julia> (1,) isa NTuple{1}
true

Upvotes: 3

Related Questions