rnso
rnso

Reputation: 24535

Should'nt there be a colon (':') in the method declaration?

I see following code from here:

+ val [
    <category: 'math'>
    ^Complex real: (realpart + val real)
        imaginary: (imagpart + val imaginary)
]
- val [
    <category: 'math'>
    ^Complex real: (realpart - val real)
        imaginary: (imagpart - val imaginary)
]

These define methods/function of + and -. I generally find the functions/methods are defined as follows (from here):

spend: amount [
    <category: 'moving money'>
    balance := balance - amount
]

Why there is no : (colon) after + and - in code mentioned above?

Thanks for your insight.

Upvotes: 1

Views: 67

Answers (1)

James Foster
James Foster

Reputation: 2210

There are three types of messages, unary, binary, and keyword. Only the keyword message has a colon. I suggest that you try out the short, on-line, tutorial at https://amber-lang.net/learn.html.

Upvotes: 4

Related Questions