This language bar is your friend. Select your favorite languages!
Select your favorite languages :
- Or search :
- C
- Clojure
- C++
- C++
- C#
- D
- Dart
- Elixir
- Fortran
- Go
- Haskell
- JS
- JS
- Java
- Java
- Java
- Java
- Java
- Kotlin
- Lisp
- Lua
- PHP
- Pascal
- Perl
- Python
- Python
- Ruby
- Rust
- Scala
- Scheme
- Scheme
std::tuple<std::string, bool> foo() {
return std::make_tuple("someString", true);
}
c++ 11
public Tuple<string, bool> foo_PreCSharp7()
{
// Only accessed via .Item1 and .Item2
return new Tuple<string, bool>("string", true);
}
public (string, bool) foo_CSharp7UnnamedTuples()
{
// Only accessed via .Item1 and .Item2
return ("string", true);
}
public (string NamedStringArg, bool NamedBooleanArg) foo_CSharp7()
{
// Can be accessed via .NamedStringArg or .NamedBooleanArg
return ("string", true);
}
C# 7 Introduced several Tuple changes which increase the complexity and variation of syntax.
auto foo()
{
return tuple("theString", true);
}
auto infers the return type, so it's Tuple!(string,bool).
interface F<A, B> { Entry<A, B> get(); }
F<String, Boolean> foo
= () -> entry("abc", true);
Entry<String, Boolean> foo() {
return entry("abc", true);
}