Skip to content

Instantly share code, notes, and snippets.

Sriram Srinivasan sriraminc

Block or report user

Report or block sriraminc

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View MutabilityKT.kt
class MutabilityKT {
//In Kotlin, you can either mention the data type of a variable
//Or let the compiler infer it. If you see below
//for string variables I have mentioned their data type and
//for "age" I let Kotlin compiler to infer.
//In Kotlin, "var" means variable and it is mutable
//"val" means constant and hence immutable.
// In the below example, "name' of a person does not change
View HelloWorld.kt
//This is a simplest code you can write in Kotlin.
//You don't need to declare a class
//Kotlin generates a class for this code.
fun main(args: Array<String>){
print("Hello Kotlin")
}
@sriraminc
sriraminc / infiniteloop.go
Created May 23, 2020
Branching and Looping in GO
View infiniteloop.go
package main
import (
"fmt"
"math/rand"
"time"
)
func main() {
@sriraminc
sriraminc / LinkedListTraversal.go
Created May 23, 2020
Branching and Looping in GO
View LinkedListTraversal.go
package main
import (
"fmt"
"math/rand"
"time"
)
type linkedList struct {
value int
@sriraminc
sriraminc / main.go
Last active May 22, 2020
Custom Data Types in Go
View main.go
package main
import (
"datatypes/organization"
"fmt"
)
func main() {
p := organization.NewPerson("Sriram", "Srinivasan", organization.NewEuropeanUnionIdentifier("my real id", "Germany"))
err := p.SetTwitterHandler("@sriraminc")
@sriraminc
sriraminc / person.go
Last active May 22, 2020
Custom Data Types in Go
View person.go
package organization
import (
"errors"
"fmt"
"strconv"
"strings"
)
type Handler struct {
@sriraminc
sriraminc / scopechain.js
Last active Apr 21, 2020
Advanced JavaScript Samples
View scopechain.js
/*
In Javascript, scope chain is an important concept that explains how your code
executes. In our sample below we have a variable "someVar" declared at various
places and we have two functions rootFun() and myFunc(). Let's see how these
are stacked in the scope chain of a JavaScript Engine
When we execute this code Javascript engine will first create a global execution context and
give it three things. A global object, this and an outer environment. In the global execution context
outer environment is nothing but the javascript engine.
@sriraminc
sriraminc / undefined.js
Created Apr 21, 2020
Advanced JavaScript Sample
View undefined.js
//undefined sample created by Sriram Srinivasan on 21/04/2020
//In JavaScript "undefined" is a special value which takes some memory as it is the
//default value assigned variables before initializing it with some value.
//In this sample, we see two cases.
//1. We will declare a variable and not initialise it
//2. We will declare a variable and initialize it with a value
//3. We will not declare a variable and use it anyways.
//4. We will assign "undefined" to a variable to see whether we can do this.
@sriraminc
sriraminc / templatestrings.js
Created Apr 21, 2020
JavaScript ES6 Samples
View templatestrings.js
//Template Strings sample in ES6.
//Written by Sriram Srinivasan on 21/04/2020
/*Template Strings provide an elegant way to embed strings in the code. Template
Strings do not ignore whitespace or newline charater. You can give an expression
in a template string and that will be evaluated. */
function customerDetails(customerName, customerAge, customerEmail) {
return `Customer name is ${customerName} Customer Age is ${customerAge +
10} and Customer Email is ${customerEmail} `;
}
@sriraminc
sriraminc / spread.js
Created Apr 21, 2020
JavaScript ES6 Samples
View spread.js
//Spread sample in ES6.
//Written by Sriram Srinivasan on 21/04/2020
/*Spread operator let's an array to be taken out and listed as an individual items. */
var nums = [1, 2, 3];
//This will print nums array content as individual elements.
console.log(...nums);
//We can merge two arrays using spread operator very easily
You can’t perform that action at this time.