在Julia中,Visual Basic"with block"等效?

Rez*_*lan 3 julia

我知道在各种编程语言中有一种块语法来简化对对象字段的过多引用的表达式

例如在VB中,可以使用以下描述的块连接:

通过使用With ... End With,您可以对指定对象执行一系列语句,而无需多次指定对象的名称.在With语句块中,您可以指定以句点开头的对象成员,就像With语句对象在其前面一样.

我想在朱莉娅做这样的事情:

With theCustomer
    .Name = "Coho Vineyard"
    .URL = "http://www.cohovineyard.com/"
    .City = "Redmond"
End With
Run Code Online (Sandbox Code Playgroud)

或者可能: @With data .a=.b+c*d

在Julia中有一个与Block相当的块吗?

Toi*_*son 8

没有,但您可以创建一个短名称的变量.如果您还想以与上述相同的方式限制范围,您可以例如

let c = theCustomer
    c.Name = "Coho Vineyard"
    c.URL = "http://www.cohovineyard.com/"
    c.City = "Redmond"
end
Run Code Online (Sandbox Code Playgroud)

不再冗长,也不需要特殊的语法.