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

Construct from MVector #57

Open
jariji opened this issue Mar 29, 2022 · 2 comments
Open

Construct from MVector #57

jariji opened this issue Mar 29, 2022 · 2 comments

Comments

@jariji
Copy link

jariji commented Mar 29, 2022

I have a StaticArrays.MVector and I want to make ShortString. Should this be possible?

julia> using StaticArrays, ShortStrings; ShortString(@MVector UInt8[1,2,3,4])
Error showing value of type ShortString{MVector{4, UInt8}}:
ERROR: DimensionMismatch("No precise constructor for MVector{4, UInt8} found. Length of input was 1.")
@tbeason
Copy link

tbeason commented Mar 30, 2022

You need to broadcast over the vector.

julia> ShortString.(@MVector UInt8[1,2,3,4])
4-element MVector{4, ShortString{UInt8}} with indices SOneTo(4):
 ""
 ""
 ""
 ""

@jariji
Copy link
Author

jariji commented Mar 30, 2022

I want to make one ShortString out of the MVector, just like I can make one String out of the MVector.

julia> String(@MVector UInt8[97,98,99])
"abc"

julia> ShortString(@MVector UInt8[97,98,99])
Error showing value of type ShortString{MVector{3, UInt8}}:
ERROR: DimensionMismatch("No precise constructor for MVector{3, UInt8} found. Length of input was 1.")

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

No branches or pull requests

2 participants