Skip to content

Instantly share code, notes, and snippets.

@torsday
Created August 22, 2013 23:27
Show Gist options
  • Select an option

  • Save torsday/6313968 to your computer and use it in GitHub Desktop.

Select an option

Save torsday/6313968 to your computer and use it in GitHub Desktop.
Comparison of function syntaxes #references #ruby #js

Comparison of function syntaxes


Ruby

def my_function(var1,var2)
   value # implicit return
end

Python

def myFunction( str ):
  "This prints a passed string into this function"
  print str
  return

JavaScript

function myFunction(var1,var2)
{
some code...
return x; // explicit return
}

see also: OO-JS

C++

#include <iostream>
using namespace std;

int myFunction (int a, int b=2, int& c)
{
  int r;
  r=a+b;
  return (r);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment