login as root.
install ruby 3.3.7 (ruby 3.4 wont work – there are some errors).
pkg_add ruby
Continue reading “Install Rails 8.0.2 on OpenBSD 7.7”A Computer Person Journey
login as root.
install ruby 3.3.7 (ruby 3.4 wont work – there are some errors).
pkg_add ruby
Continue reading “Install Rails 8.0.2 on OpenBSD 7.7”A lambda is a way to define a block and its parameter with special syntax.
greet1 = -> { puts “Hello world.” }
greet2 = lambda { puts “Hello world !” }
greet1.call
greet2.call
greet_with_param = ->(name) { puts “Hello #{name}!” }
greet_with_param.call(“Joni”)
The spaceship operator is general comparison operator. The <=> operator compares 2 values and returning -1, 0, or 1 depending on whether the first value is less than, equal, or greater than the second.
Example in irb.

This operator is used on ruby range operation , objects must implement <=> and succ method to perform range operation. Lets test the a numeric value for these methods.

Keep learning ruby on 2021.
One book that help ruby spread outside Japan. The book use Ruby 1.6 but still relevant.
Numeric variable on ruby have upto method that we can use to do looping. Normally looping is done by using while or for syntax. Ruby can do differently.

Example above we loop from 10 to 15. Its simpler right.
The basic conditional if in ruby is like any other programming language.
if condition then
[statements to execute if condition is satisfied (true) ]
end
If only a statement needed to executed then we can use shorthand form of if. Statement is at front followed by if and condition.

Ruby also have unless for conditional branching. Difference is statement will be executed if condition not satisfied (false).

Try it yourself at irb ! Bye …
Ruby programming language have constant like other language we know ? Or Ruby dont have ?
Ruby have naming convention related to variable names. If a variable name begin with upper case then its considered constant. Ruby wont stop you to change that constant, it only emit warning like a test case below on irb.

So thats Ruby’s constant.
This is an interesting command to know. We can use gem environment to find out gem files install location. Below is sample output on windows OS.

apt-get install postgresql-client sqlite3
apt-get install libpq-dev libpqtypes-dev libsqlite3-dev
gem install pg sqlite3
Digest gem on ruby 2.6 is part of standard library. No need to do “gem install digest” anymore ! Here is proof on NetBSD 9.
