Top "Idioms" questions

A programming idiom is the usual and customary way to write code in a particular language.

Golang and inheritance

I want to provide a base struct with methods in my library that can be 'extended'. The methods of this …

inheritance go idioms
How do I use Python to easily expand variables to strings?

What's a nice idiom to do this: Instead of: print "%s is a %s %s that %s" % (name, adjective, noun, …

python string variables idioms expand
Pythonic way to have a choice of 2-3 options as an argument to a function

I have a Python function which requires a number of parameters, one of which is the type of simulation to …

arguments python idioms
Best Loop Idiom for special casing the last element

I run into this case a lot of times when doing simple text processing and print statements where I am …

java loops while-loop idioms
Idiomatic use of parentheses in Ruby

array.include? 'foo' or array.include? 'bar' is a syntax error (unexpected keyword_or). Parentheses solve the problem, but as …

ruby parentheses idioms
What C++ idioms should C++ programmers use?

What C++ idioms should C++ programmers know? By C++ idioms, I mean design patterns or way of doing certain things …

c++ design-patterns idioms c++-faq
Is there an idiom in Java for empty methods which exist to satisfy an interface?

Let's say I have a class Foo implementing an interface such as MouseListener. The MouseListener interface consists of five methods …

java interface annotations oop idioms
Proper way to dynamically add functions to ES6 classes

I have a simple class with a single method exec(arg1,..,argn) and I want to have a number of …

javascript ecmascript-6 idioms
Is str.replace(..).replace(..) ad nauseam a standard idiom in Python?

For instance, say I wanted a function to escape a string for use in HTML (as in Django's escape filter): …

python performance replace idioms
Read a file and get an array of strings

I want to read a file and get back a vector of Strings. The following function works, but is there …

rust idioms