Crystal: Return default value for method?

Created on 3 Apr 2017  路  4Comments  路  Source: crystal-lang/crystal

What about something like this?

def test(value) : Int32(5)
  something_here_with_value
end

If something_here_with_value doesn't return Int32, return default value 5
I don't find any info about this...

All 4 comments

def test(value) : Int32
  something_here_with_value || 5
end

Offtop.
袗 屑芯卸薪芯 褋 褌芯斜芯泄 泻邪泻-褌芯 泻芯薪褌邪泻褌懈褉芯胁邪褌褜? 袩芯褔褌邪? 孝芯泻褋? 袞邪斜斜械褉?
袦芯褟 锌芯褔褌邪 - [email protected]

Can you keep it English and on-topic please.

@RX14 ok, no problems.
@kostya How can i contact with you? Mail? Tox? Jabber? Thanks.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

straight-shoota picture straight-shoota  路  91Comments

asterite picture asterite  路  78Comments

asterite picture asterite  路  70Comments

asterite picture asterite  路  71Comments

rdp picture rdp  路  112Comments