Title here
Summary here
Here’s the Ruby translation of the Go code example, formatted in Markdown suitable for Hugo:
Ruby has various value types including strings, integers, floats, booleans, etc. Here are a few basic examples.
# Strings, which can be concatenated with +.
puts "ruby" + "lang"
# Integers and floats.
puts "1+1 = #{1 + 1}"
puts "7.0/3.0 = #{7.0 / 3.0}"
# Booleans, with boolean operators as you'd expect.
puts true && false
puts true || false
puts !true
To run the program, save it in a file (e.g., values.rb
) and use the ruby
command:
$ ruby values.rb
rubylang
1+1 = 2
7.0/3.0 = 2.3333333333333335
false
true
false
In this Ruby example:
puts
to print output, which is similar to fmt.Println
in the original code.+
operator, just like in the original.#{}
) to embed the results directly in the output string.Ruby, being a dynamic language, doesn’t require explicit type declarations. It automatically infers the types of values, making the code more concise compared to statically-typed languages.