Here is a sample Ruby program from http://www.rubycentral.com/pickaxe/intro.html.

def sayGoodnight(name)
  result = "Goodnight, " + name
  return result
end


# Time for bed...
puts sayGoodnight("John-Boy")
puts sayGoodnight("Mary-Ellen")

Here is the same code in C'Dent:

sayGoodnight(name):
  result = "Goodnight, " ++ name
  return result

# Time for bed...
put sayGoodnight("John-Boy")
put sayGoodnight("Mary-Ellen")

As you can see the code is very similar. Let's point out the differences.

We don't need the def keyword to define a method. Just the method name, arguments in parens, and a colon. Indentation defines scope (actually {} can be used but indentation implies those), so we don't need an end statement.

++ is the string concatenation operator. We also could have used double quote interpolation:

  result = "Goodnight, $name"

We use put instead of puts. It prints out the string followed by a newline. This method comes from the IO module which is used by the CDent.Common module which is implied by default in every C'Dent program.

We could have defined the method like this:

String sayGoodnight(String name) { return "Goodnight, $name" }

This version has explicit types, but these types were implied by the usage, so the declarations are not required. (C'Dent needs to know the type of all methods and variables). Also we use curly braces to define the scope, and thus we remove the colon.