Skip to content

Commit

Permalink
Merge pull request #12 from Bigjango13/1.0.0
Browse files Browse the repository at this point in the history
Add String Indexing
  • Loading branch information
nobody5050 authored May 20, 2023
2 parents adc18d1 + 66a51e2 commit d575648
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,17 @@ let a = "hi';
let b = 'hello";
```

Strings can be zero indexed, which returns a single character long string. For example:
```
let a = "Hello";
# Prints H
print( a[0] );
# Prints true
print( a[2] == "l" );
# Throws an error (47 is more than 4)
print( a[47] );
```

- Numbers are any variable consisting of digits 0-9.
The following are valid Numbers:
```
Expand Down Expand Up @@ -445,12 +456,20 @@ x = string ( x );
print ( type ( x ) );
```

You can also get the length of a list with `len()`:
You can also get the length of a list or string with `len()`:
```
let x = [ 1, 2, 3 ];
# returns `2`
# prints `2`
print ( len( x ) );
let s = "Test";
# prints `3`
print ( len( s ) );
# prints `none`
print ( len( [] ) );
```

### Importing functions
Expand Down

0 comments on commit d575648

Please sign in to comment.