... | ... | @@ -69,7 +69,7 @@ log(MyLabel.$gtype.name); |
|
|
// expected output: Gjs_MyLabel
|
|
|
```
|
|
|
|
|
|
[`instanceof`][mdn-instanceof] can be used to compare an object instance to a constructor object.
|
|
|
[`instanceof`][mdn-instanceof] can be used to compare an object instance to a **constructor object**.
|
|
|
|
|
|
```js
|
|
|
log(typeof labelInstance);
|
... | ... | @@ -220,10 +220,12 @@ In GJS caller-allocates (variables passed into a function) and functions with mu |
|
|
```js
|
|
|
let [minimumSize, naturalSize] = label.get_preferred_size();
|
|
|
|
|
|
let file = new Gio.File({ path: '/proc/cpuinfo' });
|
|
|
let [ret, contents] = file.get_contents(null);
|
|
|
|
|
|
if (ret) {
|
|
|
log(contents);
|
|
|
// Functions with boolean 'success' returns often still throw an Error on failure
|
|
|
try {
|
|
|
let file = new Gio.File({ path: '/proc/cpuinfo' });
|
|
|
let [ok, contents, etag_out] = file.load_contents(null);
|
|
|
log(ok ? contents : 'Failed to read file: unknown error');
|
|
|
} catch(e) {
|
|
|
log('Failed to read file: ' + e.message);
|
|
|
}
|
|
|
``` |
|
|
\ No newline at end of file |