Umstieg zu JayMo / Vergleich mit PHP, Ruby, Java

Vergleich mit PHP, Ruby, Java


JayMoPHPRubyJava
Kommentar Zeilenende
# comment # comment
// comment
# comment // comment
Kommentar Mehrzeilig
/* line1
line2 */
/* line1
line2 */
=begin
line1
line2
=end
/* line1
line2 */
Befehls-Trenner
newline or ; ; newline or ; ;
Block-Trenner
indent with tabulator {} {}
do end
{}

Variablen

JayMoPHPRubyJava
Definition Variable
a = 1 $a = 1; a = 1 int a = 1;
Definition Konstante
A = 1 define("A", 1);
const A = 1;
A = 1 final int a = 1;
Inkrement, Dekrement
a=++
a=--
a.inc
a.dec
$a++;
$a--;
x = x.succ
x = x.pred
a++;
Null
nil
null
null nil null
Null-Prüfung
a.isNil
a == nil
is_null($a)
! isset($a)
a == nil
a.nil?
a == null
Logische Operatoren
&& || ^^
!&& !|| !^^
!
.and .or .xor
.nand .nor .xnor
.not
&& || !
and or xor
&& || !
and or not
&& || ^ !
Potenz
5**
5**2
5.pow
5.pow(2)
pow(5, 2) 5 ** 2 Math.pow(5, 2)
Quadratwurzel
25//
25//2
25.sqrt
25.root(2)
sqrt(25) sqrt(25) Math.sqrt(25)
Absolut-Wert
2.3.abs abs(2.3) 2.3.abs Math.abs(2.3)

Strings

JayMoPHPRubyJava
Literal
"JayMo says \"Hello\"" "PHP says \"Hello\""
'PHP says "Hello"'
"Ruby says \"Hello\""
'Ruby says "Hello"'
"Java says \"Hello\""
Text-Blöcke
""""line1
line2
line3""""
<<<BLOCK
line1
line2
line3
BLOCK;
<<BLOCK
line1
line2
line3
BLOCK
 
Verbinden
s = "Hallo " + "Welt" $s = "Hallo "."Welt"; s = "Hallo " + "Welt" String s = "Hallo " + "Welt";
Trimmen
" lorem ".trim
" lorem ".trimLeft
" lorem ".trimRight
" lorem ".trim(' ')
trim(" lorem ")
ltrim(" lorem ")
rtrim(" lorem ")
" lorem ".strip
" lorem ".lstrip
" lorem ".rstrip
" lorem ".trim()
Replizieren
"abc" * 5 str_repeat("abc", 5) "abc" * 5 String s = "abc";
String t = "";
for(int i=1; i<=5; i++)
     t = t+s;
Groß-/Klein
"Abc".upper
"Abc".lower
"Abc".caseUp
"Abc".caseDown
"Abc".toUpperCase()
"Abc".toLowerCase()
"Abc".ToUpper()
"Abc".ToLower()
"Abc".toUpperCase()
"Abc".toLowerCase()
Splitten
"Lorem ipsum".split(' ')
"Lorem ipsum" / 2
"Lorem ipsum".div(2)
"Lorem ipsum".group(6)
"Lorem ipsum".split(" ") "Lorem ipsum".Split(' ') "Lorem ipsum".split(" ")
Länge
"abc".getLength
"abc".length
"abc".len
strlen("abc") "abc".Length "abc".length()
Schneiden
"Hello".cut(2,2)
"Hello".area(2,3)
substr("Hello", 1, 3) "Hello".Substring(1,3) "Hello".substring(1,3)
Zeichen
"Hello"[2]
"Hello".get(2)
"Hello".charAt(2)
substr("Hello", 1, 1) "Hello"[1] "Hello".charAt(1)

Arrays / Listen

JayMoPHPRubyJava
Erzeugen
a = List(1, 2, 3)
a = [1, 2, 3]
$a = [1, 2, 3]; a = [1, 2, 3] int[] a = new int[]{1, 2, 3};
Länge
a.getLength
a.length
a.len
count($a) a.size
a.length
a.length()

Funktionen

JayMoPHPRubyJava
Definition
::myAdd(Int a, Int b) Int
    Return a + b

::myAdd(a, b)
    § = a + b

::myAdd(a, b) = a + b
function myAdd($a, $b) {
    return $a + $b;
}
def myAdd(a, b)
    a + b
end
private int myAdd(int a, int b) {
    return a + b;
}
Aufruf
this.myAdd(2, 3)
°myAdd(2, 3)
myAdd(2, 3); myAdd 2, 3 this.myAdd(2, 3);
- Powered by OghsWiki -

 

 

Unterstützen

Die Entwicklung von "JayMo" wird derzeit nur durch Eigeninitiative ermöglicht.

Erhalten:  0 €