<sarna>
I've never used vanilla emacs, it's too painful for me :)
gr33n7007h has joined #ruby
gr33n7007h has quit [Ping timeout: 246 seconds]
gr33n7007h has joined #ruby
<lester29>
ok, i'll go with emacs and ruby
<lester29>
i'll focus on these two things
<sarna>
have fun!
<lester29>
do you know how do I verify if user input is a number, and if not print error message and ask user gain? when I enter 'abcdef' at gets.chomp.to_i, input string is converted to 0
sphex has quit [Remote host closed the connection]
<sarna>
`to_i` returns 0 in case of failure, so it's not the best option here. try `Integer(foo)` or `Float(foo)` depending on which you want
<lester29>
ty
tallys has quit [Quit: Best CPUs can count to infinity twice without being bugged out by zero division errors or whatnot.]
<ox1eef_>
Integer(foo, exception: false).nil?
<ox1eef_>
If nil is returned you know the input is not a valid number.
<lester29>
or begin rescue
<ox1eef_>
I would avoid it.
<leftylink>
I hate it when that happens
<lester29>
i started with simple programs in ruby to avoid too much burden myself
<lester29>
such as calculator, various menu console apps
<lester29>
i can't wait to learn the rails
<lester29>
i see in my city there are well-paid jobs for ruby on rails developers
<lester29>
btw i think whether i want or not, some things i'll have to learn simultaneously such as english language, subjects required by my school
<lester29>
i'm computer science student
<lester29>
so better question would be on how to organize time efficiently instead of "should i learn it together with it"
sagax has joined #ruby
roadie has quit [Quit: ERC 5.5.0.29.1 (IRC client for GNU Emacs 29.0.92)]
Guest10 has joined #ruby
<Guest10>
what is ruby
Guest10 has quit [Client Quit]
<lester29>
what's better way to define enums? module Foo BAR = 1 or symbols?
<sarna>
there's a trick at the end - `private_constant(*constants)` - it's so that when I `include` the module, the constants are not re-exported by the class I'm including it in
<lester29>
what's the difference between putting symbols in a module instead of a class, for instance class XYZ CONSTANT_1 = :constant_1
<lester29>
why do you put your constants in modules instead of classes?
<sarna>
classes should have meaningful instances
<sarna>
in my case, `TokenType` is just a group of constants, nothing more
Spengl has joined #ruby
markong has joined #ruby
Spengl has quit [Quit: Best CPUs can count to infinity twice without being bugged out by zero division errors or whatnot.]
brokkoli_origin has quit [Quit: (Leaving)]
brokkoli_origin has joined #ruby
TomyLobo has joined #ruby
<lester29>
how can I pass parameter values by keywords without putting in the declaration of the function :foo, like in python def f(x): pass; f(x=2)?
<leftylink>
if I want to specify at the call site which argument is assigned to which parameter, I must use keyword arguments. I cannot use =, because = is an assignment to a local variable
Fuente90 has quit [Remote host closed the connection]
Fuente90 has joined #ruby
Fuente90 has quit [Remote host closed the connection]
Fuente90 has joined #ruby
dionysus69 has joined #ruby
dionysus69 has quit [Client Quit]
jess has quit [Quit: make good choices]
podge has quit [Ping timeout: 260 seconds]
buckwheatsuperpo has joined #ruby
buckwheatsuperpo has quit [Quit: Leaving...]
podge has joined #ruby
roadie has joined #ruby
gr33n7007h has quit [Ping timeout: 245 seconds]
gr33n7007h has joined #ruby
Fuente90 has quit [Remote host closed the connection]
gr33n7007h has quit [Ping timeout: 246 seconds]
gr33n7007h has joined #ruby
buckwheatsuperpo has joined #ruby
buckwheatsuperpo has quit [Quit: Leaving...]
buckwheatsuperpo has joined #ruby
CrazyEddy has quit [Ping timeout: 246 seconds]
podge has quit [Quit: Konversation terminated!]
sphex has joined #ruby
patrick has quit [Killed (NickServ (GHOST command used by podge!~patrick@fsf/member/patrick))]
patrick has joined #ruby
patrick has quit [Killed (platinum.libera.chat (Nickname regained by services))]
patrick_ has joined #ruby
patrick_ is now known as patrick
Saling89 has joined #ruby
Saling89 has quit [Quit: Best CPUs can count to infinity twice without being bugged out by zero division errors or whatnot.]
desnudopenguino1 has joined #ruby
desnudopenguino has quit [Ping timeout: 246 seconds]
desnudopenguino1 is now known as desnudopenguino
patrick has quit [Killed (NickServ (GHOST command used by podge!~patrick@fsf/member/patrick))]
patrick has joined #ruby
patrick is now known as Guest276
Guest276 has quit [Killed (erbium.libera.chat (Nickname regained by services))]
<lester29>
should I apply parentheses only before ( in the compound expression or at your discretion?
<lester29>
I mean let's suppose expressions like this Float gets.chomp vs Float(gets.chomp)
buckwheatsuperpo has quit [Quit: Leaving...]
<ox1eef_>
Up to your preference. Functionally the same.
buckwheat has joined #ruby
buckwheat has quit [Client Quit]
buckwheat has joined #ruby
Domini has joined #ruby
buckwheat has quit [Quit: WeeChat 3.8]
buckwheat has joined #ruby
keypresser86 has joined #ruby
thelounge18 has joined #ruby
<KOTP>
Float gets or Float(gets) is just style. No need to use chomp at all, since a number will not have a newline, so no reason to remove it with an additional method call.
buckwheat has quit [Quit: WeeChat 3.8]
buckwheat has joined #ruby
buckwheat has quit [Client Quit]
buckwheat has joined #ruby
buckwheat has quit [Client Quit]
buckwheat has joined #ruby
buckwheat has quit [Quit: WeeChat 3.8]
buckwheat has joined #ruby
Domini has quit [Quit: Best CPUs can count to infinity twice without being bugged out by zero division errors or whatnot.]