Skip to content

Instantly share code, notes, and snippets.

public delegate TResult Converter(T input);
public delegate TResult Converter<T, TResult>(T input);
public class ListHandler
{
private readonly IRepository _repository;
public ListHandler(IRepository repository)
{
_repository = repository;
}
public ListMoviesViewModel Execute()
public ListMoviesViewModel ListHandler(inject IRepository repository)
{
return new ListMoviesViewModel { Movies = _repository.Query<Movie>() };
}
void Main()
Print("Hello, World!")
int Factorial(int n)
if (n==0)
1
else
n * Factorial(n-1)
int Main()
Factorial(10)
int Main()
{
int height = 5
length = 10
height * length
}
//Value types can be made nullable, like in C#:
int a = 1
int? b = null
//But even reference types are non-nullable by default in Rook:
string str = null // Compile error!
string? nullableStr = null // OK
int[] digits = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
int[] firstFive = digits[0:5]
int[] lastFive = digits[5:10]
int[] interiorFive = digits[3:8]
firstFive.Append(100) // Equals [0, 1, 3, 4, 100]
interiorFive.With(2, 100) // Equals [3, 4, 100, 6, 7]
int[] digits = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
int[] firstFive = digits[0:5]
int[] lastFive = digits[5:10]
int[] interiorFive = digits[3:8]
firstFive.Append(100) // Equals [0, 1, 3, 4, 100]
interiorFive.With(2, 100) // Equals [3, 4, 100, 6, 7]