HexLibraryHexLibrary
</> HexCodeSign inSign up
PythonJavaScriptTypeScriptCC++JavaPHPGoRustRubyBashSQLLuaPerlCOBOLPascalDelphiFortranDartSwiftC#JuliaGroovyRElixirHaskellKotlinScalaClassic ASPClipperMS-DOS
LESSONS
Introduction to JuliaVariablesData TypesOperatorsStringsArraysConditions (if / else)Loops (for / while)Functions
REFERENCE
📖 Overview
🖥️ Output
📦 Variables & Types
🔢 Numbers & Math
✍️ String
📚 Array & Dictionary
🔀 Condition & Loop
🧩 Function
function ... endSingle-line function
Julia›REFERENCE›Function
🧩

Function

function...end and single-line definition.

CommandDescription
function ... endDefines your own command.
Single-line functionShort, single-expression functions.

function ... end

Try it yourself →

Defines your own command.

Syntax

function name(params) ... return ... end

Description

Defined with function, closed with end. return yields the result (the last expression is also automatically returned). Global is not needed inside functions.

Example

function square(x)
    return x * x
end
println(square(5))

Expected output

25

When to use?

Preventing code repetition, breaking the program into parts.

Single-line function

Try it yourself →

Short, single-expression functions.

Syntax

name(params) = expression

Description

Short functions are written in a single line as f(x) = expression. Does the same thing as function...end — just more readable.

Example

addUp(a, b) = a + b
greet(name) = "Hello $name"
println(addUp(8, 9))
println(greet("Julia"))

Expected output

17
Hello Julia

When to use?

Short helper functions, mathematical definitions.

HexLibraryHexLibrary

Learn programming more clearly. Every command is explained line by line with colors, reinforced with runnable exercises, test your code instantly — all in one place, free.

Learn

  • Home
  • Languages & Lessons
  • HexCode

Company

  • About
  • Contact

Legal

  • Privacy Policy
  • Terms of Use

Other Projects

  • HexToolz
  • Free Service Manuals
© 2026 HexLibrary · The clearest way to learn code