This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# I see the locale visible in the token but then it disappears | |
# error_log("[777] Before Prepared Decoded Token: " . print_r($decoded, true)); | |
# $valid_token_data = $this->prepare_token($decoded, $user->ID); | |
( | |
[data] => stdClass Object | |
( | |
[user] => stdClass Object | |
( | |
[id] => 224175 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static ChannelReader<T> CreateScheduleMessenger<T>(ChannelReader<T> channelReader, | |
Command command) | |
{ | |
var output = Channel.CreateUnbounded<T>(); | |
Task.Run(async () => | |
{ | |
if (command is Command.Get) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fn main() { | |
let s = String::from("book"); | |
// Add code here that calls the pluralize function | |
let many = pluralize(s.clone()); | |
println!( | |
"I have one {}, you have two {}", | |
s, | |
many, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public sealed class MyTuple<T1, T2> : IEquatable<MyTuple<T1, T2>> | |
{ | |
// Create Instance for Comparing Against Self. | |
// If we used type against Interface we can compare two values | |
private static readonly IEqualityComparer<T1> FirstComparer = EqualityComparer<T1>.Default; | |
private static readonly IEqualityComparer<T2> SecondComparer = EqualityComparer<T2>.Default; | |
private readonly T1 _first; | |
private readonly T2 _second; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Generic | |
public void Swap<T>(ref T lhs, ref T rhs) | |
{ | |
T temp; | |
temp = lhs; | |
lhs = rhs; | |
rhs = temp; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int a = 1; | |
int b = 2; | |
string aa = "Hello"; | |
string bb = "World"; | |
Swap<int>(ref a, ref b); | |
Swap(ref a, ref b); // we can even ignore being explicit about the type. | |
Swap(ref aa, ref bb); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void SwapInt(ref int lhs,ref int rhs) | |
{ | |
int temp; | |
temp = lhs; | |
lhs = rhs; | |
rhs = temp; | |
} | |
public void SwapString(ref string lhs, ref string rhs) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Fact] | |
public void ThisIsSafe() | |
{ | |
int a = 5; | |
int b = a + 2; //OK | |
bool test = true; | |
// Error. Operator '+' cannot be applied to operands of type 'int' and 'bool'. | |
int c = a + test; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ExplicitTyping | |
{ | |
// This would have failed in C# 1 and 2, prior to the introduction of var in 3.0 | |
// https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/var | |
[Fact] | |
public void ImplicitTypingWillFail() | |
{ | |
var s = "Hello"; | |
var x = s.Length; | |
var twiceX = x * 2; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class StaticallyTypedCSharp | |
{ | |
[Fact] | |
public void StaticTypeWontCompile() | |
{ | |
Object o = "Hello"; | |
Assert.True(o.Length == 5); | |
} | |
NewerOlder