Replies: 3 comments
-
Hi @2colours , the error I'm getting is "cannot assign to a read-only variable or value": ~$ cat ~/key_test_4_bruce.txt
1 KEY2
2 VAL21
3 VAL22
4 VAL23
5 VAL24 Now conventional sigil (works fine): ~$ raku -ne 'my ($k, $v) = .split: "\t"; say $k => $v;' ~/key_test_4_bruce.txt
1 => KEY2
2 => VAL21
3 => VAL22
4 => VAL23
5 => VAL24 Now with "sigil-less" variables: ~$ raku -ne 'my (\k, \v) = .split: "\t"; say \k => \v;' ~/key_test_4_bruce.txt
\("k" => \("KEY2"))
Cannot assign to a readonly variable or a value
in block <unit> at -e line 1 Note: I tried hinting the compiler by adding a numeric parameter to |
Beta Was this translation helpful? Give feedback.
-
Hi @jubilatious1 , I can't see here where you are doing anything that involves sigilless variables without destructuring - the |
Beta Was this translation helpful? Give feedback.
-
Hi @2colours Let me try that: % raku -ne 'my (\k, \v) = .split: "\t"; say \k , \v;' ~/key_test_4_bruce.txt
\("1")\("KEY2")
Cannot assign to a readonly variable or a value
in block <unit> at -e line 1
% raku -ne 'my \k = .split: "\t"; say \k ;' ~/key_test_4_bruce.txt
\(("1", "KEY2").Seq)
\(("2", "VAL21").Seq)
\(("3", "VAL22").Seq)
\(("4", "VAL23").Seq)
\(("5", "VAL24").Seq)
% raku -ne 'my \k = .split("\t").List; say \k ;' ~/key_test_4_bruce.txt
\(("1", "KEY2"))
\(("2", "VAL21"))
\(("3", "VAL22"))
\(("4", "VAL23"))
\(("5", "VAL24"))
% raku -ne 'my (\k,\v) = .split("\t").List; say \k,\v ;' ~/key_test_4_bruce.txt
\("1")\("KEY2")
Cannot assign to a readonly variable or a value
in block <unit> at -e line 1 |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
This is just a cheap way for me to add a quick note: the binding issue seems to be tied to destructuring in particular;
my \k = .split: "|";
will work just fine,my (\k, \l) = .split: "|";
will cause problems.PS: By the way, could the Github Discussions tab turned on for this repo? It's probably simpler for adding notes like this than fully blown issues.
Beta Was this translation helpful? Give feedback.
All reactions