This repository has been archived by the owner on Jun 20, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #38 from Thecarisma/master
Feature : Syntax : Add the `final` keyword to make a final variable initialization once
- Loading branch information
Showing
19 changed files
with
313 additions
and
84 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
|
||
/* | ||
KEYWORD : final | ||
FUNCTIION : To lock a variable to only one initialization, to prevent assigning new value to a | ||
variable that not meant to change value. | ||
USE CASE : In the @File Console module the **stdout** is a final variable to prevent initializing it to something | ||
else to prevent runtime error while using the @File Console blocks and classes | ||
*/ | ||
|
||
flexibleDuck = "This is a changable variable anytime any where" | ||
final finalVar = "This remain throughout execution" | ||
final aClass = new AClass | ||
try { | ||
aClass.setPath("a new path") | ||
catch | ||
@__err__ | ||
} | ||
|
||
@flexibleDuck | ||
@finalVar | ||
|
||
flexibleDuck = "Well the duck is an animal" | ||
try { | ||
finalVar = "Try changing to another value" | ||
catch | ||
@__err__ | ||
} | ||
|
||
@aClass.getPath() | ||
@flexibleDuck | ||
@finalVar | ||
@InerFinal() | ||
|
||
|
||
block InerFinal() | ||
final innerFinal = "inner final variable" | ||
notFinal = "desi" | ||
|
||
notFinal = "indoian" | ||
innerFinal = "Try changing it throw an error" | ||
|
||
@innerFinal | ||
|
||
class Parent | ||
|
||
final path = "foo ? bar ? whatever " | ||
|
||
block getPath() | ||
return path | ||
|
||
class AClass : Parent | ||
|
||
block setPath(p) | ||
this.path = p |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.