20 questions
4
votes
1
answer
116
views
C#/.NET: why can't I pass ref readonly variable into another method that require ref readonly variable?
Consider this code:
struct Struct { public int Num; }
class Program
{
public void A(ref readonly Struct s) { }
public void B(ref readonly Struct s) => A(ref s);
}
I get a compilation ...
0
votes
1
answer
40
views
Can you have init-once variables in C# extension methods?
Extension methods operate on an instance of a class, but they are implemented as static methods inside a static class. It seems that they don't allow declaring any variables static or readonly.
Here ...
1
vote
2
answers
164
views
Create a readonly pointer argument of any type in C
I want to make a macro that when given a type T, will return a pointer type that is readonly when passed to a function, like so:
void foo( readonly_ptr(char) str )
{
// can only read from str, not ...
0
votes
0
answers
189
views
BASH bug or feature?: Shadowing a readonly global variable with a writable local variable
(Possibly this is the same question as Function local read-only vs. global read-only variable with the same name)
In a script I wrote I'm using readonly key="$1" (for the program parameter) ...
0
votes
0
answers
386
views
Cannot convert value of type '() -> [Any]' to specified type '[(TextFormatType, UIButton)]'
I'm getting error when i try to extract toolbarStyles from here and create a read-only computed property.
private func toolbarButtons(toolbar: Toolbar) {
guard let selection = getSelection() else ...
-1
votes
3
answers
485
views
What is the difference between `state` and `const`?
It seems similar to write:
use Const::Fast;
const $xx, 77;
sub test {
do_something_with( $xx );
}
or
sub test {
state $xx = 77;
do_something_with( $xx );
}
What is the better ...
0
votes
2
answers
322
views
How can we check whether a variable is readonly or not in linux [duplicate]
How can we check under if whether a variable is readonly or not? Please Explain with Examples
1
vote
2
answers
1k
views
Changing value of readonly array
I have this jagged array in C#:
private static readonly float[][] Numbers = {
new float[]{ 0.3f, 0.4f, 0.5}};
How can I override the value?
public static void SetNewNumbers(float[][] num){
...
3
votes
1
answer
288
views
How do I change a Perl Readonly scalar in a module for a unit test?
The only help I've found on the internet so far is this blog. Which I thought was going to get me there, but I don't think it's actually changing the values in my module. I made a sample to show what ...
2
votes
1
answer
525
views
Why does Powershell not throw an error when we do $NULL="FOO"?
I was trying to understand how the constants $TRUE, $FALSE and $NULL work in Powershell, and how I should test for them or compare them with variables, respectively.
Being a Powershell newbie, I did ...