-
Notifications
You must be signed in to change notification settings - Fork 2
04. Functions
-
Functions return their last expression value. Use that as an implicit return.
Sqr(X:int):int = X * X # Implicit return
-
If using any explicit returns, all returns in the function should be explicit.
-
Getters or functions with similar semantics that may fail to return valid values should be marked
<decides><transacts>
and return a non-option type. The caller should handle potential failure.GetX()<decides><transacts>:x
-
An exception is functions that need to unconditionally write to a
var
. Failure would roll the mutation back, so they need to uselogic
oroption
for their return type.
-
Use extension methods instead of a function with a single typed parameter.
-
Doing this helps Intellisense. By typing
MyVector.Normalize()
instead ofNormalize(MyVector)
it can suggest names with each character of the method name you type. For example:(Vector:vector3).Normalize<public>():vector3
-
Do not:
Normalize<public>(Vector:vector3):vector3
Use of the Unreal Engine, Unreal Editor for Fortnite and Verse is governed by the terms of the Unreal® Engine End User License Agreement.
A majority of this content was taken from VERSE DOCUMENTATION Such content belongs to EPIC GAMES
Verse icon, UEFN, UEFN icon, Unreal Engine, Unreal Engine logo, Fortnite, & Fortnite icon are property of EPIC GAMES
This github is not maintained or endorsed by EPIC GAMES. It is made for educational purposes only.
This wiki was compiled by Lil Wikipedia