ref

Refs for dynamically generated components in React?

半腔热情 提交于 2020-01-02 17:35:13
问题 The code below is a minimal working example to explain my problem. This code generates 3 Note components using Array.map and when you hit enter in them it empties the statically generated Note component above them using a ref to its DOM element. What I want to do is instead have the Note you hit enter in empty itself. I think this would require generating a dynamic array containing {id, ref} for each Note, so I could pass the Note id to handleKeyDown then search the refs array for that id and

ref for variables not parameters in functions

不想你离开。 提交于 2020-01-01 07:38:29
问题 Suppose I have a Person class and have the following: Person A = new Person("Tom"); Person B = A; Is there a way I can change it so that if I assign a new Person to B , B = new Person("Harry") , A would be referring to the same instance too? I know you can do that in a ref parameter assignment in a function. 回答1: UPDATE: The feature described here was added to C# 7. The feature you want is called "ref locals" and it is not supported in C#. The CLR does support generating code that contains

How to save a ref variable for later use?

杀马特。学长 韩版系。学妹 提交于 2019-12-29 07:24:51
问题 So this works.. public MyClass(ref Apple apple) { apple = new Apple("Macintosh"); // Works fine } But is it possible to do something like this? private Apple myApple; public MyClass(ref Apple apple) { myApple = apple; } public void ModifyApple() { myApple = new Apple("Macintosh"); // does not change the input variable like the first example did } When the ref variable is copied to the member variable myApple it appears to lose it's 'ref-ness' and re-assigning it no longer changes the input

How can I get ref text when I have many refs in kivy label?

折月煮酒 提交于 2019-12-25 16:42:48
问题 Please help. I have many refs in label and when user click on first ref how can i get ref text on main.py? I need python method which can get this ref text. Label: markup: True text: "[ref=first ref]First ref[/ref] ,[ref=second ref]Second ref[/ref]" on_ref_press: # here I need method that can return ref.text 回答1: All the arguments passed to the event handler are available in kv via the args variable. The arguments to the on_ref_press handler are instance, refvalue . So, for example: Label:

Sending property as a reference param to a function in iOS?

╄→гoц情女王★ 提交于 2019-12-25 06:31:40
问题 I want to do something like this: @property (nonatomic, retain) NSObject *obj1; @property (nonatomic, retain) NSObject *obj2; - (id)init { if ((self = [super init])) { [SomeClass someFuncWithParam1:*(self.obj1) param2:*(self.obj2)]; } } @implementation SomeClass + (void)someFuncWithParam1:(NSObject **)param1 param2:(NSObject **)param2 { //init obj1; ... //init obj2; ... } @end I haven't found any example how to pass objective-C properties into a function for initialization. I know that it is

What is the use passing Class Object using keyword “ref”? They are by by default pass by reference [duplicate]

為{幸葍}努か 提交于 2019-12-24 10:58:35
问题 This question already has answers here : What is the use of “ref” for reference-type variables in C#? (10 answers) “ref” keyword and reference types [duplicate] (4 answers) Closed 5 years ago . I just noticed .net allows us to do like this. public void Func1(ref String abc) { } I was wondering "ref" keyword makes any sense???? as String is a Class(reference type) Is it any different from. public void Func1(String abc) { } I am just asking as i am confused. either missing some concept or they

npm ref could not locate the bindings file error

安稳与你 提交于 2019-12-24 00:40:01
问题 I'm using the package ref in my nodejs project that makes use of electron. But the problem is when I use ref in my JS code, it throws an error that it could not locate the bindings file. Here's the error Error: Could not locate the bindings file. Tried: → C:...\EMVModule.asar\node_modules\ref\build\binding.node → C:...\EMVModule.asar\node_modules\ref\build\Debug\binding.node → C:...\EMVModule.asar\node_modules\ref\build\Release\binding.node → C:...\EMVModule.asar\node_modules\ref\out\Debug

C# Indexers with Ref Return Gets that also Support Sets

戏子无情 提交于 2019-12-23 12:45:03
问题 Am I doing something wrong here, or as of C# 7.2 Indexers that return by ref and allow set are not supported? Works: public ref byte this[int index] { get { return ref bytes[index]; } } Works too: public byte this[int index] { get { return bytes[index]; } set { bytes[index] = value; } } Fails: public ref byte this[int index] { get { return ref bytes[index]; } set { //<-- CS8147 Properties which return by reference cannot have set accessors bytes[index] = value; } } Fails too: public ref byte

Perl Array References and avoiding “Type of arg 1 to keys must be hash” error

帅比萌擦擦* 提交于 2019-12-23 07:57:36
问题 I have a scalar $subscribers that could be undef, reference to a HASH, or reference to an ARRAY. I have assigned the sample values $VAR1 , $VAR2 and $VAR3 for testing. I'm only interested in $subscribers when it is a reference to an ARRAY, where by it would contain multiple values. In other cases, I'm not interested in printing anything (e.g. when $subscribers=$VAR2; The code seems to run fine under Perl v5.16.2; however, when I move it to the target machine running Perl v5.8.8, I get a

Delegate with ref parameter

喜欢而已 提交于 2019-12-23 07:11:01
问题 Is there any way to maintain the same functionality in the code below, but without having to create the delegate? I'm interfacing with a 3rd-party API that contains a number of various DeleteSomethingX(ref IntPtr ptr) methods and I'm trying to centralize the code for the IntPtr.Zero check. private void delegate CleanupDelegate(ref IntPtr ptr); ... private void Cleanup(ref IntPtr ptr, CleanupDelegate cleanup) { if (ptr != IntPtr.Zero) { cleanup(ref ptr); } } 回答1: If you mean without declaring