Search
 
SCRIPT & CODE EXAMPLE
 

RUBY

question mark in ruby

# methods ending with `?` usually return boolean values (true/false)
# the question mark is just a part of the method's name it's not a special syntax

# It's possible to define a method with a `?` at the end that doesn't return
# boolean values but it's considered a bad practice.

PRIME_NUMBERS = Set[2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97].freeze

def prime?(number)
  PRIME_NUMBERS.include?(number)
end

prime?(2) #=> true
prime?(1) #=> false
Comment

PREVIOUS NEXT
Code Example
Ruby :: merge two binary trees sloved in ruby 
Ruby :: singning in using username rails 
Ruby :: apple calendar gem in rails 
Ruby :: ruby basic arithmetic 
Ruby :: elsif ruby 
Ruby :: paranoia gem 
Ruby :: rails activerecord saved_change_to 
Ruby :: rails callback STI 
Ruby :: what is ruby 
R :: convert latin accents to ascii R 
R :: list all installed packages in r 
R :: empty plot in r 
R :: reduce list in parallel r 
R :: how to convert all columns of a dataframe into factors in r 
R :: r rename columns 
R :: how to read file in r 
R :: sort in descending order in r 
R :: null count in r 
R :: show 2 ggplots together 
R :: change all columns type in R 
R :: regression in r with many variables 
R :: dataframe to r code 
R :: r remove regex from string 
R :: find nas in a vector r 
R :: r glm select all variables 
R :: list variables r 
R :: store list in data.frame R 
R :: change the font of the title in a plot in r 
Rust :: random number generator in rust 
Rust :: rust count occurrences of a substring 
ADD CONTENT
Topic
Content
Source link
Name
9+5 =