Functions return the value that the final expression in them evaluated to.

function foo(x)
  x +=2
  5
end # => always returns 5

function bar(x)
  # blah blah ...
  println("hello world")
end # => always returns nothing, because that's what println returns

-- Leah


On Fri, May 23, 2014 at 5:00 PM, Dom Luna <dluna...@gmail.com> wrote:

> That cleared it up, thanks! Do functions that don't explicitly return
> anything then implicitly return Nothing?
>
> Sorry I didn't catch the FAQ section, might it be better to have that as a
> short section in types?
>
> Dom
>
>
> On Friday, May 23, 2014 3:19:35 PM UTC-4, Stefan Karpinski wrote:
>
>> This FAQ entry may answer the question:
>>
>> http://docs.julialang.org/en/latest/manual/faq/#
>> nothingness-and-missing-values
>>
>> If not, maybe we can expand it or clarify whatever's not clear.
>>
>>
>> On Fri, May 23, 2014 at 2:40 PM, Dom Luna <dlun...@gmail.com> wrote:
>>
>>> I just have general curiosity about the Nothing type, is there anything
>>> one should particularly know about it? Is it similar to a None type that
>>> one would typically find in pattern matching, ex. an Option type where it
>>> can be either Something or None, etc.
>>>
>>> I feel like Nothing and patterns for its use aren't well documented to
>>> this point.
>>>
>>> Dom
>>>
>>
>>

Reply via email to