This tag is used for questions about similarities between any of various programming constructs. Comparisons include correspondences between API, functionality, syntax, features, methodologies and the like.
Questions tagged [equivalent]
369 questions
517
votes
24 answers
XSLT equivalent for JSON
Is there an XSLT equivalent for JSON? Something to allow me to do transformations on JSON like XSLT does to XML.

luvieere
- 37,065
- 18
- 127
- 179
247
votes
5 answers
is there a Java equivalent to null coalescing operator (??) in C#?
Is it possible to do something similar to the following code in Java
int y = x ?? -1;
More about ??

Nikita Ignatov
- 6,872
- 2
- 34
- 34
146
votes
6 answers
Is there a python equivalent of Ruby's 'rvm'?
Q: Do we have anything functionally equivalent in Python to the Ruby version manager 'rvm'?
(RVM lets you easily switch completely between different versions of the ruby interpreter and different sets of gems (modules). Everything concerning…

conny
- 9,973
- 6
- 38
- 47
104
votes
17 answers
What is the equivalent of memset in C#?
I need to fill a byte[] with a single non-zero value. How can I do this in C# without looping through each byte in the array?
Update: The comments seem to have split this into two questions -
Is there a Framework method to fill a byte[] that might…

Jedidja
- 16,610
- 17
- 73
- 112
78
votes
9 answers
How would you do the equivalent of preprocessor directives in Python?
Is there a way to do the following preprocessor directives in Python?
#if DEBUG
< do some code >
#else
< do some other code >
#endif

intrepion
- 38,099
- 4
- 24
- 21
64
votes
7 answers
What is the equivalent of the Java BigDecimal class in C#?
BigDecimal is a class in the java.math package that has a lot of benefits for handling big numbers of a certain scale. Is there an equivalent class or data type in c# with this feature.

Radi
- 6,548
- 18
- 63
- 91
57
votes
7 answers
Readable C# equivalent of Python slice operation
What is the C# equivalent of Python slice operations?
my_list = ['a', 'b', 'c', 'd', 'e', 'f', 'g']
result1 = my_list[2:4]
result2 = my_list[1:]
result3 = my_list[:3]
result4 = my_list[:3] + my_list[4:]
Some of it is covered here, but it is ugly…

LJNielsenDk
- 1,414
- 1
- 16
- 32
41
votes
7 answers
What's the C++ idiom equivalent to the Java static block?
I have a class with some static members, and I want to run some code to initialize them (suppose this code cannot be converted into a simple expression). In Java, I would just do
class MyClass {
static int field1;
static int field2;
…

einpoklum
- 118,144
- 57
- 340
- 684
25
votes
2 answers
Is `const constexpr` on variables redundant?
cppreference states that:
A constexpr specifier used in an object declaration or non-static
member function (until C++14) implies const.
Does "object declaration" mean "any variable declaration"?
I.e. is
constexpr const int someConstant =…

Pharap
- 3,826
- 5
- 37
- 51
25
votes
4 answers
Java TreeMap equivalent in C#?
Most places I've consulted say to use SortedList, but the problem is that the program I'm porting actually uses duplicate keys (differentiated by order), which is permissible with TreeMap, but not SortedList.
Any advice?
user58817
25
votes
1 answer
DATEADD equivalent in PostgreSQL
Is there an equivalent to this T-SQL command in PostgreSQL?
select dateadd(hh,duration_in_hours,start_date) as end_date
I have found only interval keyword with subsequent string, but this terrible construction returns syntax error:
select…

Hink
- 1,054
- 1
- 15
- 31
25
votes
2 answers
Is there an equivalent in C++ of PHP's explode() function?
Possible Duplicate:
Splitting a string in C++
In PHP, the explode() function will take a string and chop it up into an array separating each element by a specified delimiter.
Is there an equivalent function in C++?

reformed
- 4,505
- 11
- 62
- 88
24
votes
5 answers
What is the equivalent of setTimeOut() javascript to Android?
I need the equivalent code of setTimeOut(call function(),milliseconds); for android.
setTimeOut(call function(),milliseconds);

José Francisco Lara Aguilar
- 297
- 1
- 2
- 5
23
votes
6 answers
In Ruby, what is the equivalent to an interface in C#?
I'm currently trying to learn Ruby and I'm trying to understand more about what it offers in terms of encapsulation and contracts.
In C# a contract can be defined using an interface. A class which implements the interface must fulfil the terms…

fletcher
- 13,380
- 9
- 52
- 69
23
votes
2 answers
Python pandas equivalent for replace
In R, there is a rather useful replace function.
Essentially, it does conditional re-assignment in a given column of a data frame.
It can be used as so:
replace(df$column, df$column==1,'Type 1');
What is a good way to achieve the same in…

ivan-k
- 811
- 1
- 7
- 20