Given a Ruby class with a static method like  class Foo   def self.bar     puts "Hello"   end end   I always accessed the method via  Foo.bar   However, I just noticed that you can also do  Foo::bar   Why is that? Is there a semantic difference? My initial idea was that it's a matter of treating Foo as a class object (in which case the first version seems plausible) vs. treating it as a "namespace" like a module, in which case the second version makes sense.
Simple question, but one that I've been curious about...is there a functional difference between the following two commands?  String::class String.class   They both do what I expect -- that is to say they return Class -- but what is the difference between using the :: and the .?  I notice that on those classes that have constants defined, IRB's auto-completion will return the constants as available options when you press tab after :: but not after ., but I don't know what the reason for this is...
.NET How to check if path is a file and not a directory? I have a path and I need to determine if it is a directory or file.    Is this the best way to determine if the path is a file?  string file = @"C:\Test\foo.txt";  bool isFile = !System.IO.Directory.Exists(file) &amp;&amp;                           System.IO.File.Exists(file);   For a directory I would reverse the logic.  string directory = @"C:\Test";  bool isDirectory = System.IO.Directory.Exists(directory) &amp;&amp;                              !System.IO.File.Exists(directory);   If both don't exists that then I won't go do either branch.  So assume they both do exists. I've seen lots of examples of making an entire regular expression case-insensitive.  What I'm wondering about is having just part of the expression be case-insensitive.  For example, let's say I have a string like this:  fooFOOfOoFoOBARBARbarbarbAr   What if I want to match all occurrences of "foo" regardless of case but I only want to match the upper-case "BAR"s?  The ideal solution would be something that works across regex flavors but I'm interested in hearing language-specific ones as well (Thanks )  Edit  The link Espo provided was very helpful.  There's a good example in there about turning modifiers on and off within the expression.  For my contrived example, I can do something like this:  (?i)foo*(?-i)|BAR   which makes the match case-insensitive for just the foo portion of the match.  That seemed to work in most regex implementations except Javascript, Python, and a few others (as Espo mentioned).    The big ones that I was wondering about (Perl, PHP, .NET) all support inline mode changes. Creating a large amount of convex polygons using existing coordinates The Stack Overflow search shows questions twice. See  for example.  Results include "A: Add Search Engine into MVC Music Store" and "Q: Add Search Engine into MVC Music Store".  Why is search displaying the question twice, and what does "Q" and "A" mean?  Edit:   @Stephen answer :  The search is returning both a question (Q) and an answer (A) to the question, as both posts match your search criteria.  and my another question  If the question have multiple (like 100) answer ,then the answer link(A: Question Link) shown 100 times?  Is it correct functionality ? But i saw only one answer link , not a other answer link .. why ? How do I remove objects after building them, for example a fence that I placed without taking into account its orientation? I have right clicked on it like you would a structure but nothing happened. I have also tried Shift+Alt+Click and nothing has happened. I couldn't think of any other solutions as this is my first game. Should an apostrophe be used with a z at the end of a word? I know that if a word ends with an s then it should be made plural or possessive by use of an apostrophe with no extra s (e.g. "Thomas Harris' book was a riveting read." as opposed to "Gary Barlow's voice is so distracting.")  What about if the word ends with a z. For example, would it be Gomez' album or Gomez's album? I'm trying to understand the derivation of the equations for the logistic regression. I'm following the cs229 notes:    At some point in the derivation, in the notes we need to maximize the log-likelihood of the parameters:  ℓ(θ) = log L(θ) = y log h(x) + (1 - y) log(1-h(x))  In the notes, after the derivation we get:  $\frac{\partial}{\partial \theta_j}$ = (y $\frac 1 {h(x)}$ - (1 - y) $\frac 1 {1 - h(x)}$) $\frac{\partial}{\partial \theta_j}$h(x)  Shouldn't this be:  $\frac{\partial}{\partial \theta_j}$ = (y $\frac 1 {h(x)}$ + (1 - y) $\frac 1 {1 - h(x)}$) $\frac{\partial}{\partial \theta_j}$h(x)  I've been looking at this for a while and I can't see where this minus sign is coming from...  Thanks for your help! Calculate daily sums using python pandas Can the size of pointers vary between data and function pointers? Dependence of Friction on Area Is  really independent of area? The friction force, $f_s = \mu_s N$. The equation says that friction only depends on the normal force, which is $ N = W = mg$, and nature of sliding surface, due to $\mu_S$.   Now, less inflated tires experiences more friction compared to well inflated tire. Can someone give clear explanation, why friction does not depend on area, as the textbooks says? What is the $\sqrt{i^4}$?   $i^4$ = $(i^2)^2$ So is $\sqrt{i^4}$ = $\sqrt{(i^2)^2}$ = $i^2$ = $-1$?  Or is $\sqrt{i^4}$ = $\sqrt{1}$ = $1$?  When I plug it into my TI-89 Titanium, I get $1$.  Edit: I now see why $i^4 \neq -1$. $$\sqrt{x^2} = \left|{x}\right| $$ So$$\sqrt{(i^2)^2} = \left|i^2\right| = \left|-1\right| = 1$$ When I try to remove Java with sudo apt-get remove jdk1.8.0-40 I get this:    Reading package lists... Done Building dependency tree        Reading state information... Done The following packages will be REMOVED:   jdk1.8.0-40 0 upgraded, 0 newly installed, 1 to remove and 0 not upgraded. 1 not fully installed or removed. After this operation, 245 MB disk space will be freed. Do you want to continue? [Y/n] y (Reading database ... 231488 files and directories currently installed.) Removing jdk1.8.0-40 (1.8.040-1) ... find: `/usr/java/*': No such file or directory /var/lib/dpkg/info/jdk1.8.0-40.postrm: line 586: /usr/sbin/alternatives: No such file or directory /var/lib/dpkg/info/jdk1.8.0-40.postrm: line 598: /usr/sbin/alternatives: No such file or directory dpkg: error processing package jdk1.8.0-40 (--remove):  subprocess installed post-removal script returned error exit status 127 Errors were encountered while processing:  jdk1.8.0-40 E: Sub-process /usr/bin/dpkg returned an error code (1)   Output of  ls -1 /var/cache/apt/archives/*jdk*:  openjdk-7-jre_7u75-2.5.4-1~trusty1_amd64.deb openjdk-7-jre-headless_7u75-2.5.4-1~trusty1_amd64.deb   Output of sudo dpkg --purge --force-all jdk1.8.0-40:  (Reading database ... 231488 files and directories currently installed.) removing jdk1.8.0-40 (1.8.040-1) ... /var/lib/dpkg/info/jdk1.8.0-40.postrm: line 586: /usr/sbin/alternatives: No such file or directory /var/lib/dpkg/info/jdk1.8.0-40.postrm: line 598: /usr/sbin/alternatives: No such file or directory dpkg: error processing package jdk1.8.0-40 (--purge): subprocess installed post-removal script returned error exit status 127 Errors were encountered while processing:  jdk1.8.0-40   When trying the edit I get this:  (Reading database ... 231488 files and directories currently installed.) Removing jdk1.8.0-40 (1.8.040-1) ... /var/lib/dpkg/info/jdk1.8.0-40.postrm: line 586: /usr/sbin/alternatives: Permission denied /var/lib/dpkg/info/jdk1.8.0-40.postrm: line 598: /usr/sbin/alternatives: Permission denied dpkg: error processing package jdk1.8.0-40 (--remove):  subprocess installed post-removal script returned error exit status 126 Errors were encountered while processing:  jdk1.8.0-40 E: Sub-process /usr/bin/dpkg returned an error code (1) Why don't we consider jerk in physics classes? When I got more into physics, I started asking myself if just like acceleration represents the growth of speed, something else could also represent the growth of acceleration itself. And it came that is exists and is called jerk. Before I thought about this, I thought that acceleration was the highest derivative that made sense on physics.  My question is, why can we perform accurate calculations without account for jerk? I never needed it in a single physics class! I've also read that it is seldom used.  Also, while position, speed and acceleration seem familiar to me due to everyday experience, why doesn't jerk seem familiar to me? I never tell someone when driving a car "you're jerking too much", whereas I could say "you are accelerating too much".  Is it that jerk has little influence because it is almost constant? Even if it is not, what about higher order derivatives? Why don't derivatives higher than acceleration have much influence on calculations? We perform a lot of reasoning in everyday life without resorting to it! Run a command without making me wait Free vector graphic images, for commercial use Is there a free library of vector graphics for commercial use? How do I make a Lightning Bow in vanilla Minecraft? I'm trying to make a setup with command blocks that summons lightning at the location of a shot arrow. The setup should recognize the arrow that is shot or the bow that is used by its name or another property, so that lightning only strikes at that specific arrow.   Also, the lightning should only strike once when the arrow hits the ground. I know this is somehow possible with scoreboard, but I'm no good with that. Does anyone know how to make a Lightning Bow in vanilla Minecraft? According to  , gold badge holders can now unilaterally close questions as duplicates. I hold seven gold badges for tags on SO, which means I can, on my own, close questions as duplicates for those tagged questions.  Simply put: DO NOT WANT.  However, I do not see any ability in SO (the only SE site I spend much time in) to opt out of any privileges, let alone this one.  Is there a spot that I'm just not seeing that allows me to turn off this new privilege? Is there any field of characteristic two that is not $\mathbb{Z}/2\mathbb{Z}$ Is there any field of characteristic two that is not $\mathbb{Z}/2\mathbb{Z}$?  That is, if a field is of characteristic 2, then does this field have to be $\{0,1\}$? Opening a context menu (with the Menu key) How to mass rename files with ill-formed numbering? I've got bunch of files with ill-formed numbering:  prefix-#.ext       | for files with number 1-9 prefix-##.ext      | for files with number 10-99 prefix-###.ext     | for files with number 100-999   Due to further processing I need all of their names to be in format: prefix-###.ext. Is there any easy way to do that?