|
Parallel Visions: City of Angels City of Demons ebook and trade paperback available on Amazon (or here). |
![]() |
|||
Ruby code snippets
Some useful Ruby code snippets
- 7 random characters
-
('a'..'z').to_a.shuffle[0..7].join
- create an object and assign value(s) then assign to variable
-
obj = SomeClass.new.tap { |obj| obj.key = 'value' }
See: Ruby - #tap that!
Some interesting things to try in Rugy
- pass by reference or pass by value test
-
def foo(bar) bar = 'reference' end; baz = 'value'; foo(baz); puts "Ruby is pass-by-#{baz}"
as versusdef foo(bar) bar.replace 'reference' end; baz = 'value'; foo(baz); puts "Ruby is pass-by-#{baz}"
See: Is Ruby pass by reference or by value? - Stack Overflow
Code style notes
- assignment to local variable in function call for clarity/documentation purposes
-
obj.func( some_flag = true )
(note: need to test this and/or find out about possible side effects)
Code Snippet
Ruby (Computer Language)
- Adding Ordered Metadata Fields to Samvera Hyrax
- Effective Ruby: 48 Specific Ways to Write Better Ruby
- Hello world.rb
- Installing Ruby (notes)
- Programming Ruby: The Pragmatic Programmer's Guide
- Read filtered lines.rb
- Read lines recurse.rb
- Ruby (computer language)
- Ruby code snippet
- Ruby code snippets
- Ruby links
- Sandbox ruby
- Ruby
- Ruby Code Snippet
- Ruby Example
- Ruby Script
Recent Related Changes
Topics recently changed in List (category):
- Fritz's recent reading list
- Fritz's recent reading list 2026 January to April
- Character by function
- Fritz's reading recommendations
- Fritz's to read stack
- Detective noir fantasy and SF
- Prison break science fiction
- List of Fritz's fiction reviews
- List of Fritz's fiction settings
- List of Fritz's fiction published
- List of Fritz's fiction research topics
Recent Topics with Comments
- Fritz's recent reading list
- Second-order Mary Sue
- Read as Audiobook
- Cryptozoic!
- The Demolished Man
- The Age of Ruin
- Among Others
- Adventure Time - A review of Dispensing Justice at SuperheroNovels.com (link)
- Goodbye to All Cats
- Example of telling rather than showing from Dispensing Justice
- Code Duello
Categories[edit]
- Code (category)
- Code Snippet (category)
- Has Data Table (category)
- Has DynamicPageList (category)
- Has Image (category)
- Has Infobox (category)
- Has Layout (category)
- Has LayoutList (category)
- Has Navbox (category)
- Has Tags (category)
- List (category)
- Note (category)
- Notes (category)
- Ruby (Computer Language) (category)
- Ruby Code Snippet (category)
- Snippet (category)
