I know in various programming languages there is a block syntax to simplifies expressions that have too much references to the fields of an object
e.g. in VB one can use with block whith following description:
By using With...End With, you can perform a series of statements on a specified object without specifying the name of the object multiple times. Within a With statement block, you can specify a member of the object starting with a period, as if the With statement object preceded it.
I want to do something like this in Julia:
With theCustomer
.Name = "Coho Vineyard"
.URL = "http://www.cohovineyard.com/"
.City = "Redmond"
End With
or maybe:
@With data .a=.b+c*d
Is there a With block equivalent in Julia?
There is not, but you can just create a variable with a short name instead. If you also want to limit the scope in the same way as above, you can do e.g.
let c = theCustomer
c.Name = "Coho Vineyard"
c.URL = "http://www.cohovineyard.com/"
c.City = "Redmond"
end
Not much more verbose, and doesn't require special syntax.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With