Instantiate the type from a few strings

When working with Julia, there may be times when you need to instantiate a type from a few strings. This can be achieved in different ways, depending on your specific requirements and preferences. In this article, we will explore three different approaches to solve this problem.

Approach 1: Using eval

One way to instantiate a type from strings is by using the eval function. This function evaluates a given expression as Julia code. Here’s an example:


eval(Meta.parse("MyType("string1""

Rate this post

Leave a Reply

Your email address will not be published. Required fields are marked *

Table of Contents