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?”:What is the _snowman param in Ruby on Rails 3 forms for? - Stack Overflow

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?”:performance - What is the fastest method for selecting descendant elements in jQuery? - Stack Overflow

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 >=”:python - Why < is slower than >= - Stack Overflow

I love the way Python lets you “disassemble your program”:dis — Disassembler for Python bytecode — Python 3.11.2 documentation , wonderful feature.

h3. “C#: what is the difference between i++ and ++i?”:c# - What is the difference between i++ and ++i? - Stack Overflow

“Eric Lippert”:Log In ‹ Eric Lippert's Blog — WordPress 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?”:haskell - What is <*> called and what does it do? - Stack Overflow

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”:security - Modelling a permissions system - Stack Overflow

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?”:c# - Are .Net switch statements hashed or indexed? - Stack Overflow

You learn something new every day, the C# compiler does some funky magic when it complies a “switch” statement.

Comments

Daniel_Sobral over 13 years ago
Daniel_Sobral

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).

Sam Saffron over 13 years ago
Sam Saffron

Daniel,

Thanks for the clarification, it’s funny in C# if you had the same problem you would use a type cast eg: (string)null to ensure the right overload was called.

Thanks so much for your note!

Cheers

C_Mc_Cann over 13 years ago
C_Mc_Cann

Well, I was wondering why I was suddenly getting a bunch of upvotes on an answer from three weeks ago. Thanks for the kind words! Being a C# coder by day, getting mentioned in the same list as Eric Lippert really makes my day, haha.

Sam Saffron over 13 years ago
Sam Saffron

It is an amazing answer! It makes me want to start coding Haskell again


comments powered by Discourse