Stack Overflow Weekly Newsletter
Stack Overflow Weekly Newsletter

Top new questions this week:

How do I avoid the "self.x = x; self.y = y; self.z = z" pattern in __init__?

I see patterns like def __init__(self, x, y, z): ... self.x = x self.y = y self.z = z ... quite frequently, often with a lot more parameters. Is there a good way to avoid this ...

python python-decorators namedtuple  
asked by MaxB 82 votes
answered by Siphor 38 votes

What is the purpose of a single pound/hash sign (#) on its own line in the C/C++ preprocessor?

I have been looking at the Boost libraries source code, and I have noticed that often there are single pound signs without any preprocessor directives attached to them. I read through the GCC ...

c++ c boost c-preprocessor  
asked by callyalater 55 votes
answered by Jonathan Wakely 90 votes

Why does the statement "2i;" NOT cause a compiler error?

Instead of 2*i, I carelessly wrote 2i: int foo(int i) { 2i; return 2i; } I expected the compiler to catch the error. But it did not. So is 2i a valid statement in C? If so what does it do? ...

c syntax  
asked by daltonfury42 48 votes
answered by iharob 62 votes

Difference between C# and Java's ternary operator (? :)

I am a C# newbie and I just encounter a problem. There is a difference between C# and Java when dealing with the ternary operator (? :). In the following code segment, why does the 4th line not work? ...

java c# ternary-operator conditional-operator  
asked by blackr1234 43 votes
answered by Jeroen Vannevel 56 votes

Is "typedef" in between the type and the alias standard-conformant?

I stumbled upon some code where the typedef keyword is in between the type and the alias name like in int typedef INT; It compiles in gcc and clang (live example). I am not very good in ...

c++ c language-lawyer typedef  
asked by Claas Bontus 32 votes
answered by John Bode 11 votes

Why does assigning short to byte only work when the short is final?

Can someone please explain why the following compiles: final short s1 = 1; final char c1 = 1; byte b1 = s1; byte b2 = c1; But the following doesn't (the compiler error message is Type mismatch: ...

asked by MATH000 32 votes
answered by Maroun Maroun 44 votes

Are C/C++ fundamental types atomic?

Are C/C++ fundamental types, like int, double, etc., atomic, e.g. threadsafe? Are they free from data races; that is, if one thread writes to an object of such a type while another thread reads from ...

c++ c multithreading atomic  
asked by carmellose 31 votes
answered by James Adkison 49 votes

Greatest hits from previous weeks:

AngularJS: Service vs provider vs factory

What are the differences between AngularJS module's Service, Provider and Factory?

angularjs dependency-injection angularjs-service angularjs-factory angularjs-provider  
asked by Lior 2081 votes
answered by Lior 2067 votes

What is the difference between an interface and abstract class?

What exactly is the difference between an interface and abstract class?

java oop interface abstract-class  
asked by Sarfraz 760 votes
answered by e-satis 1169 votes

Can you answer these?

LinkedIn doesn't fetch metadata when sharing website

I'm having issues with sharing a website I'm working on on LinkedIn: LinkedIn doesn't fetch any data from the page. The site's metadata follows the recommendations in their docs. I tried all these ...

html share linkedin opengraph meta-tags  
asked by Yngve Høiseth 5 votes

Oracle.DataAccess DataRow.Field<decimal> InvalidCastException

In my code I was using System.Data.OracleClient for ora database connection. I would like to replace this library (because it is obsolete) with Oracle.DataAccess. Unfortunately I found that ...

c# oracle  
asked by Václav Starý 8 votes

Programatically write to an android device

I would like to write a program in java that copies mp3 files from my PC, renames them so they sort correctly, and transfers them to the sdCard on my Android phone via USB. I assumed this would be a ...

java android filesystems  
asked by G-Cam 4 votes
Subscribe to more Stack Exchange newsletters

Unsubscribe from this newsletter or change your email preferences by visiting your subscriptions page on

Questions? Comments? Let us know on our feedback site. If you no longer want to receive mail from Stack Exchange, unsubscribe from all emails.

Stack Exchange, Inc. 110 William St, 28th Floor, NY NY 10038 <3