Skip to content

Instantly share code, notes, and snippets.

View hk1ll3r's full-sized avatar
👨‍💻
Happily Coding

Hoss hk1ll3r

👨‍💻
Happily Coding
  • No Such Studio
  • Planet Earth
View GitHub Profile
@hk1ll3r
hk1ll3r / 20200127-valuetuples-2.cs
Last active January 27, 2020 23:01
gist 2: call using the shorthand syntax
// declare and assign
(float x, float y) = GetPosition();
// just assign
float x, y; // declare variables elsewhere
(x, y) = GetPosition();
// tuple usage (explicit)
ValueTuple<float, float> ret = GetPosition();
float x = ret.Item1, y = ret.Item2;
@hk1ll3r
hk1ll3r / 20200127-valuetuples-1.cs
Last active January 27, 2020 22:52
gist 1: basic usage
float x, y;
public ValueTuple<float, float> GetPosition() {
return ValueTuple.Create(_x, _y);
}
// Is exactly the same as GetPosition above
public (float, float) GetPositionAlternateSyntax() {
return (_x, _y);
}
@hk1ll3r
hk1ll3r / 20200127-valuetuples.cs
Last active January 27, 2020 22:57
gist to demonstrate c# 7.0's new value tuple syntax for returning multiple values from functions.
using System;
public struct Vector2 {
public float x;
public float y;
public Vector2(float x, float y) {
this.x = x;
this.y = y;
}
}