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

Papierkorb picture Papierkorb  路  3Comments

TechMagister picture TechMagister  路  3Comments

cjgajard picture cjgajard  路  3Comments

nabeelomer picture nabeelomer  路  3Comments

pbrusco picture pbrusco  路  3Comments