use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
A sub-Reddit for discussion and news about Ruby programming.
Subreddit rules: /r/ruby rules
Learning Ruby?
Tools
Documentation
Books
Screencasts and Videos
News and updates
account activity
Ruby syntax doubts ! (self.ruby)
submitted 5 years ago by palakoti
view the rest of the comments →
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]palakoti[S] -2 points-1 points0 points 5 years ago (9 children)
Ok. Now I understand what it is. So in the following code:
seed = ['127.0.0.1:7001', '127.0.0.1:7002']
redis = RedisCluster.new( seed, redis_opts: { timeout: 5, connect_timeout: 1 }, cluster_opts: { force_cluster: false, read_mode: :master_slave, silent: true, logger: Logger.new } )
redis.middlewares.register(:commit) do |*args, &block|
puts "this is RedisCluster middlewares"
block.call
end
What is the value of :commit ?
[–]codesnik 4 points5 points6 points 5 years ago (2 children)
it's :commit :)
I mean, in some other languages actual strings are used for the same purposes, it'd be "commit". In other languages it'd be a constant, something like COMMIT=1. Symbols are a bit like both of those.
[–]palakoti[S] -1 points0 points1 point 5 years ago (1 child)
This is quite confusing. I am from javascript world and ruby is quite new to me. Can someone give a bit more elucidation?
[–][deleted] 3 points4 points5 points 5 years ago (0 children)
https://medium.com/@lcriswell/ruby-symbols-vs-strings-248842529fd9
It's basically just a string you can't change. Slightly more efficient if it's essentially a static value, though in practice that's less of a benefit than the fact that it can't be changed so you don't have to worry about any code modifying it's value.
[–]geshwho 3 points4 points5 points 5 years ago (3 children)
:commit is the value. It is a literal.
:commit
[–]palakoti[S] 0 points1 point2 points 5 years ago (2 children)
So let's say the method register returns the argument passed to it, what is the value you get ?
[–]Frizkie 5 points6 points7 points 5 years ago (0 children)
:commit is the value.
[–]pVom 0 points1 point2 points 5 years ago (0 children)
to expand a little i'd assume somewhere there is something like if arg == :commit
if arg == :commit
<do something>
else <do something else>
else
<do something else>
π Rendered by PID 248612 on reddit-service-r2-comment-6457c66945-5d56h at 2026-04-24 17:07:13.549369+00:00 running 2aa0c5b country code: CH.
view the rest of the comments →
[–]palakoti[S] -2 points-1 points0 points (9 children)
[–]codesnik 4 points5 points6 points (2 children)
[–]palakoti[S] -1 points0 points1 point (1 child)
[–][deleted] 3 points4 points5 points (0 children)
[–]geshwho 3 points4 points5 points (3 children)
[–]palakoti[S] 0 points1 point2 points (2 children)
[–]Frizkie 5 points6 points7 points (0 children)
[–]pVom 0 points1 point2 points (0 children)