BashOOP/example/script.sh

34 lines
484 B
Bash
Raw Normal View History

2021-12-27 23:44:16 +00:00
#!/bin/bash
OOP_ROOT=..
. $OOP_ROOT/oop.sh # Import library.
# Import library
2021-12-27 23:44:16 +00:00
importNamespace Example.shn
# OOP Example
Example.Object obj1 "First Object"
Example.Object obj2 "Second Object"
2021-12-27 23:44:16 +00:00
$obj1.print
# The $ is not mandatory, but is recommanded.
obj2.print
2021-12-27 23:44:16 +00:00
objs=($obj1 $obj2)
${objs[0]}.print
${objs[1]}.print
2021-12-27 23:44:16 +00:00
$obj1.name = "New name"
$obj1.print
# Static example
Example.Static.print "Example text"
# Using directive.
using Example
Object usingObj "New"
$usingObj.print