Until the declaration of character strings (String) and numerical values (Int) and the confirmation of the process of outputting them at the same time.
Ruby
sample.rb
#The comment line is"#"Described in
moji = "ABC" #String
suji = 123 #Numerical value
#This way of writing is NG
# puts moji + suji
#This way of writing is OK
puts moji + suji.to_s
$ ruby sample.rb
ABC123
Python3
sample.py
moji = "ABC"
suji = 123
#This way of writing is NG
# print(moji + suji)
#This way of writing is OK
print(moji + str(suji))
$ python test.py
ABC123
Swift
sample.swift
import Foundation
var moji = "ABC"
var suji = 123
//This way of writing is NG
//print(moji + suji)
//This way of writing is OK
print(moji + String(suji))
(playground)
ABC123
Java
sample.java
package sample;
public class Main {
public static void main(String[] args) {
String moji = "ABC";
int suji = 123;
//Java is OK with this writing style
System.out.println(moji + suji);
}
}
(eclipse console)
ABC123
C#
sample.cs
using System;
public class HelloWorld {
static public void Main () {
String moji = "ABC";
int suji = 123;
// C#This way of writing is OK
Console.WriteLine(moji + suji);
}
}
(Execute using'mono'in the execution environment at hand)
$ mcs sample.cs
(Compile successful)
$ mono sample.exe
ABC123
The content I'm learning is ahead of me, so I want to output more and more.
Recommended Posts