Skip to content

Instantly share code, notes, and snippets.

int main() {
Map myMap = {
1: 3,
'Peter': 5,
1.2: "hi",
};
print(myMap[1]); // Will print 3.
print(myMap['Peter']); // Will print 5
print(myMap[1.2]); // Will print "hi"
int main() {
var myList = [1, "Hello", 3, 4.4, 5];
myList[2] = "World";
for (int i = 0; i < 5; i++) {
print("${myList[i]} ");
}
void main() {
greeting("Ram");
print("The sum of 10 and 20 is ${add(10, 29)}.");
canWatchMovie(12);
greeting3();
greeting3(name: "Lakshman");
print("The ares of rectange of length 10 and width 20 is ${areaOfRectangle(length: 19, width: 20)}");
}
void main() {
var myStr1 = "Elementary,";
var myStr2 = "My dear Watson";
var myInt = 221;
// String concatenation.
print(myStr1 + ' ' + myStr2 + '.');
// String interpolation.
void main() {
// String with single quotes.
var myStr1 = 'I\'m gonna make him an offer he can\'t refuse.\n';
// String with double quotes.
var myStr2 = "I'm the king of the world.\n";
// Multi line string.
var myStr3 = '''
void main() {
var myVar1 = "The one ring to rule them all."; // myVar1 will be of type String.
var myVar2 = 1; // myVar2 will be of type int.
var myVar3 = 1.1; // myVar3 will be of type double.
print(myVar1.runtimeType);
print(myVar2.runtimeType);
print(myVar3.runtimeType);
}
void main() {
dynamic myDynamicVar;
myDynamicVar = 10;
print(myDynamicVar);
myDynamicVar = 3.14;
print(myDynamicVar);
@sumeetmathpati
sumeetmathpati / dbg.h
Created June 29, 2020 16:07
C debug macros
#ifndef __dbg_h__
#define __dbg_h__
#include <stdio.h>
#include <errno.h>
#include <string.h>
#ifdef NDEBUG
#define debug(M, ...)
#else