Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there an opposite of the underscore( _ ) line continuation?

The underscore allows me to do things like this

    Public Sub derp _
        (x As Integer)
        MsgBox(x)
    End Sub

Is there any opposite notation for this? For example, if it was ¯ then I could do

Public Sub derp(x as Integer) ¯ Msgbox(x) ¯ End Sub
like image 410
user81993 Avatar asked Nov 08 '22 21:11

user81993


1 Answers

You can try using a colon. But you can't put the function/sub body in the same line as the declaration of the function/sub.

Public Sub derp(x As Integer)
    MsgBox(x) : MsgBox("Hello, world") : End Sub

You can also try using an action delegate. But it can only have 1 statement if you want to put them in 1 line.

Public herp As Action(Of Integer) = Sub(x) MsgBox(x)

If you want to have multiple line, you write it like this (you can use colons, if you want):

Public herp As Action(Of Integer) = Sub(x)
                                        MsgBox(x)
                                        MsgBox("Hello, world")
                                    End Sub

Use Func delegate if you want to return a value instead of Action delegate.

like image 110
Han Avatar answered Nov 14 '22 22:11

Han