This file contains hidden or 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
type slice struct { | |
array unsafe.Pointer | |
len int | |
cap int | |
} |
This file contains hidden or 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
cart := []string{"apple", "pear", "milk"} | |
fruits := cart[:2] | |
fruits = append(fruits, "lemon") | |
fmt.Println("cart:", cart, "fruits:", fruits) |
This file contains hidden or 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
[DEBUG] year -> 2022 | |
2022 |
This file contains hidden or 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
from datetime import datetime | |
class LoggingProxy: | |
"""Log attribute access to proxied object.""" | |
def __init__(self, obj): | |
self._obj = obj | |
def __getattr__(self, attr): | |
val = getattr(self._obj, attr, None) |
This file contains hidden or 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
from datetime import datetime | |
class LoggingProxy: | |
"""Log attribute access to proxied object.""" | |
def __init__(self, obj): | |
self._obj = obj | |
def __getattribute__(self, attr): | |
val = getattr(self._obj, attr, None) |
This file contains hidden or 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
#!/bin/bash | |
case $1 in | |
-h | --help ) echo "usage: $(basename $0) [VERSION]"; exit;; | |
esac | |
if [ $# -gt 1 ]; then | |
1>&2 echo "error: wrong number of argument" | |
exit 1 | |
fi |
This file contains hidden or 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
haystack = "Where's Wally?" | |
needle = 'Waldo' | |
if needle in haystack: | |
print('Found Waldo') | |
else: | |
print('Waldo not found') |
This file contains hidden or 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
Found Waldo |
This file contains hidden or 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
haystack = "Where's Wally?" | |
needle = 'Waldo' | |
if haystack.find(needle): | |
print('Found Waldo') | |
else: | |
print('Waldo not found') |
This file contains hidden or 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
arr := [...]string{"A", "B", "C"} | |
fmt.Println(len(arr)) // 3 |