Why is my function passing 10 as a parameter? I would like to add onClick listeners to my buttons in Unity, C#. I have an array of these buttons. I am trying to loop through that array, and for each button, I am adding an onClick listener which calls a function that takes an index parameter. In that function, I print out the paramater that the function has received. However, when I click on one of these buttons, I get 10 as an output every time. for(int i = 0; i &lt; roleButtons.Length; ++i) {     roleButtons[i].onClick.AddListener(delegate { changeEquipment(i); }); }  void changeEquipment(int index) {     Debug.Log(index); //Here I got 10 as an output after every single click. }
Captured variable in a loop in C# I met an interesting issue about C#. I have code like below.  List&lt;Func&lt;int&gt;&gt; actions = new List&lt;Func&lt;int&gt;&gt;();  int variable = 0; while (variable &lt; 5) {     actions.Add(() =&gt; variable * 2);     ++ variable; }  foreach (var act in actions) {     Console.WriteLine(act.Invoke()); }   I expect it to output 0, 2, 4, 6, 8. However, it actually outputs five 10s.  It seems that it is due to all actions referring to one captured variable. As a result, when they get invoked, they all have same output.  Is there a way to work round this limit to have each action instance have its own captured variable?
What's the simplest way to call Http GET url using Delphi? There's a web services I want to call in my application, I can use it with importing the WSDL or by just use "HTTP GET" with the URL and parameters, so I prefer the later because it's simple thing.  I know I can use indy idhttp.get, to do the job, but this is very simple thing and I don't want to add complex indy code to my application.  UPDATE: sorry if I was not clear, I meant by "not to add complex indy code", that I don't want add indy components for just this simple task, and prefer more lighter way for that. Can anyone explain how one would convert one voltage range to another? I'm going to need to convert a range of -10 to +10 volts into a range of 0 to +5 volts. How would this be accomplished? Thanks!   Let me say  something more. Inside of a torpedo there are gyroscopes. This gyroscope give -10 volts when the torpedo have 180 degrees of deviation to the west and 10 volts when the deviation is to the east. This signal is DC, so i need to change this range a range: 0 to 5 v DC . Thanks What Hogwarts classes are taught to two houses at once? How to solve this limit: $\lim\limits_{x\to0}\frac{(1+x)^{1/x}-e}x$? I tried to evaluate $$\lim_{x\to0}\frac{(1+x)^{1/x}-e}x$$but all my efforts were in vain . L'Hospital rule becomes very complicated. Am I too old for academia after a PhD? I've tried to read and understand this:   As a test, since my layout is "Polish, programmer" in the /usr/share/X11/xkb/symbols/pl file I played with remapping the 'q' character to 'x', and it worked just fine.  But what I want, is to remap LWIN (Left Super) to Left Control.   So I tried this: I started editing /usr/share/X11/xkb/symbols/pc file, assuming this is the 'root' of all the other files. Commented out this line:  //key &lt;LWIN&gt; {  [ Super_L       ]   };   and added this one:  key &lt;LWIN&gt; {    [ Control_L     ]   };   and rebooted PC, with no success. I.e. LWIN + C, doesn't copy selected text in text editors to clipboard, instead it just produces the 'c' letter. In the terminal instead of stopping current programm it also just produces the 'c' letter.  Here is my config file:   When I try the xev command and then press the Left Control Key, I see this:  KeyPress event, serial 40, synthetic NO, window 0x5a00001,     root 0x7e, subw 0x0, time 1053321, (374,-259), root:(374,545),     state 0x0, keycode 133 (keysym 0xffe3, Control_L), same_screen YES,     XKeysymToKeycode returns keycode: 37     XLookupString gives 0 bytes:      XmbLookupString gives 0 bytes:      XFilterEvent returns: False  KeyRelease event, serial 40, synthetic NO, window 0x5a00001,     root 0x7e, subw 0x0, time 1053425, (374,-259), root:(374,545),     state 0x0, keycode 133 (keysym 0xffe3, Control_L), same_screen YES,     XKeysymToKeycode returns keycode: 37     XLookupString gives 0 bytes:      XFilterEvent returns: False   BTW. Ask ubuntu suggests me two links to similar questions, but they are old, and suggest using xmodmap, and afaik it's no longer correct answer on Ubuntu >= 16.04 (Xenial) and this is precisely the version I have.  BTW2. I would really like to avoid using apps like Xbindkeys, considering there is a built in solution, which I guess I almost understand, and already spent some time on trying to understand it. What's the difference between the atomic and nonatomic attributes? What do atomic and nonatomic mean in property declarations?  @property(nonatomic, retain) UITextField *userName; @property(atomic, retain) UITextField *userName; @property(retain) UITextField *userName;   What is the operational difference between these three? So far, I didn't have the chance to use either of these services. Before starting, I would like to hear your opinions. What are the advantages and disadvantages? Why should I choose one over the other? I am mainly interested in the technical side, but I would also love to hear comments also regarding the plans and prices. We can prove that there is no integer $n&gt;1$ such that $2^n-1\mid 3^n-1$. This leads to the following question:     Is it true that for every pair of primes $p&lt;q$ there are only finitely many integers $n$ such that $p^n-1\mid q^n-1$? Are there two primes $p&lt;q$ and an integer $n&gt;p+q$ such that $p^n-1\mid q^n-1$?Is it true that if $n&gt;6$ then $2^n-1\nmid 5^n-1$?   Edit: Here are some examples: \begin{array}{ll} 2^{36}-1\mid 41^{36}-1, &amp;3^{12}-1\mid 97^{12}-1,\\ 5^{6}-1\mid 37^{6}-1, &amp;7^{4}-1\mid 151^{4}-1. \end{array}  Now I prove there is no integer $n&gt;1$ such that $2^n-1\mid 3^n-1.$  Proof: Denote $A=2^n-1$ and $B=3^n-1$. If $n$ is even then $3$ divides $A$ but not $B$, a contradiction.  If $n$ is odd then $A\equiv -5\pmod {12}$. Since every prime greater than $3$ is $\equiv \pm1,\pm5 \pmod {12}$, some prime factor $p$ of $A$ must be congruent to $\pm5 \pmod {12}$. As $p \mid B$, we have $3^{n+1}\equiv 3 \pmod p$. Since $n+1$ is even, we get $(\frac{3}{p})=1$, a contradiction again. How to handle :java.util.concurrent.TimeoutException: android.os.BinderProxy.finalize() timed out after 10 seconds errors? Can I use Bluray as a boot cd? How to Drag and Drop files to open application? Since Ubuntu 18.04 I can't drag a file e.g. image file to an open application such as Inkscape or  email message window. In Ubuntu 17.10 I was able to select the image file by clicking on it, and while holding down left mouse button I would hit the supper key displaying all open windows where for there I could then drop the file in any open app or folders. This is no longer possible/default behaviour since Ubuntu 18.04. Is there a workaround that would allow me to achieve this or even a way to recreate the same behaviour like in 17.10? Enable copy and paste on UITextField without making it editable How to properly ignore exceptions I'd like to make links to all files in a directory tree. Which means, create the same directory structure and make the links in them to the respective subdirectory in the original dir.  That could be done with   cp -R -s ../foo .   But - that needs an absolute path. So rather  cp -R -s `readlink -e ../foo` `readlink -e .`   I would like the resulting links to be relative.  How would I do that? Razr Maxx HD, How to wipe data with broken screen My screen is totally destroyed, it's black and unresponsive. The phone turns on just fine, though. I just got my new phone and I have to send this one back now.  I want to wipe the phone before I send it back, but I'm not sure how. I don't care too much about sending back a rooted phone, it seems Asurion doesn't really care about that from what I've read, but I don't want my personal data on the phone when I send it in.  What are my options to wipe the phone without a screen? I've already read a lot of threads on other forums and here on the subject, but everyone seems to say to wipe through ADB shell. Well, I can see the phone in ADB, but I am unable to enter SU through ADB shell. I assume it's because the screen is locked, and I have no way to unlock it. Others have also said to wipe through fastboot in ADB, but I am seeing conflicting recommendations and I'm not sure how to proceed. I'm not that proficient with ABD, so I want to make sure I don't mess this up.  Any advice would be greatly appreciated. What are the automorphisms acting on $Q\sqrt[3]{2}$ that fixes Q? Does $A$ a UFD imply that  $A[T]$ is also a UFD? I'm trying to prove that $A$ a UFD implies that $A[T]$ is a UFD.   The only thing I am sure I could try to use is Gauss's lemma.  Also, how can we deduce that the polynomial rings $\mathbb{Z}[x_1,\ldots,x_n]$ and $k[x_1,\ldots,x_n]$ are UFDs? Can I use grep matches to execute command? I need to upgrade php from 5.3 to 5.4. I've installed it with rpm. I want clean install: delete all 5.3 packages, and install all necessary 5.4. Here is the command to see all installed packages:  rpm -qa |grep php   It prints out a list of packages, and I want to remove all them with:  rpm -e *pakage.name*   Can I iterate over all matches in grep results and use each match in:   rpm -e *grep.match* Function on $[a,b]$ that satisfies a Hölder condition of order $\alpha > 1 $ is constant I want to show that if a function $f:[a,b]\rightarrow \mathbb R$ satisfies a Hölder condition of order $\alpha &gt; 1 $ then it is constant.  The way I think of it is as follows:  $$|f(x) - f(y)| &lt; K|x-y|^\alpha$$  $$\frac{|f(x) - f(y)|} {|x-y]}  &lt; K|x-y|^{\alpha -1}$$  $$\lim_{y\rightarrow x} \frac{|f(x) - f(y)|} {|x-y]} \le \lim_{y\rightarrow x}  K|x-y|^{\alpha -1} =0 $$ As the limit is $0$, we can remove the modulus, so we get:  $$\lim_{y\rightarrow x} \frac{f(x) - f(y)} {x-y} = 0$$ So $f$ is derivable and $f'(x) = 0$ for all $x$ in $[a,b]$. Note that the reason we can add the limit $y\rightarrow x$ is because $[a,b]$ is closed in $\mathbb R$.  However, the question gives as a hint using the mean value theorem. I am not sure why one should do that. You would first have to prove that $f$ is derivable in a similar manner to what I did, and then prove that $f$ is constant. Or is there a simpler way to do it and I am missing it?  Also please inform me of any mistakes I did in the proof (if any)/ Thank you!