Interesting answers on Stack Overflow from July
over 10 years ago
At my new job I have been looking at better ways of highlighting recent interesting answers.
Here is a list of 10 answers I came across in July that I found interesting. I tried to keep this language agnostic.
So here is my top 10 list:
What do the &=
and =&
operators do?
Why did PHP decide to have an assign by reference construct, why?
Defeating a Poker Bot
The most upvoted non-wiki answer on Stack Overflow for July. This answer came in months after the question was asked, it is really comprehensive. I loved the ideas about shifting all the pixels and throwing glitches, brilliant.
h3. “What is the _snowman param in Rails 3 forms for?”:http://stackoverflow.com/questions/3222013/what-is-the-snowman-param-in-rails-3-forms-for/3348524#3348524
Rails 3 will ship with a hack to work around oddities with … Internet Explorer and unicode. I love the creativity of the solution, and everybody loves a snowman ☃.
h3. “What is the fastest method for selecting descendant elements in jQuery?”:http://stackoverflow.com/questions/3177763/what-is-the-fastest-method-for-selecting-descendant-elements-in-jquery/3177782#3177782
For those writing javascript answers, “jsfiddle”:http://jsfiddle.net/ can make your answer so much more awesome. I love an answer that puts in the extra effort and measures performance.
h3. “Why < is slower than >=”:http://stackoverflow.com/questions/3369304/why-is-slower-than/3369477#3369477
I love the way Python lets you “disassemble your program”:http://docs.python.org/library/dis.html , wonderful feature.
h3. “C#: what is the difference between i++ and ++i?”:http://stackoverflow.com/questions/3346450/c-what-is-the-difference-between-i-and-i/3346729#3346729
“Eric Lippert”:http://blogs.msdn.com/b/ericlippert/ usually has the definitive answer to any intricate question you have about C#, he also happens to have to most comprehensive answers to the most trivial questions.
h3. “Haskell: How is <*> pronounced?”:http://stackoverflow.com/questions/3242361/haskell-how-is-pronounced/3242853#3242853
This is my favorite answer I came across, wow.
h3. “Scala - how to explicitly choose which overloaded method to use when one arg must be null?”:http://stackoverflow.com/questions/3169082/scala-how-to-explicitly-choose-which-overloaded-method-to-use-when-one-arg-must/3169147#3169147
I am no Scala programmer, however I found the way Scala casting syntax to a bit prettier than the C# syntax, I like that it is more concise.
h3. “Modelling a permissions system”:http://stackoverflow.com/questions/3177361/modelling-a-permissions-system/3177578#3177578
At some point in time we all hit a point where we need to design a permission system, this is a good summary of our options.
h3. “Are .Net switch statements hashed or indexed?”:http://stackoverflow.com/questions/3366376/are-net-switch-statements-hashed-or-indexed/3366497#3366497
You learn something new every day, the C# compiler does some funky magic when it complies a “switch” statement.
A small note here, but to cast x to String in Scala, one would use “x.asInstanceOf[String]â€. The answer used “x: String†instead, which is an altogether different thing — a type ascription.
A type cast tells the compiler to assign a type no matter what evidence the compiler has about the correct type. A type ascription tells the compiler to assign a type while taking into account the evidence about the correct type.
A practical difference is that a type ascription may return a compile time error but will never throw an exception, while a type cast may throw an exception but will never return a compile time error.
In the example, null is a valid instance of both String and List[String], so it works in those cases. However, “null: Int†would result in compile time error, while “null.asInstanceOf[Int]†would compile fine (and might even work due to boxing).