Values
Values in Rhyme represent the actual data - strings, numbers, booleans, and more. Understanding how to work with different value types is essential for building dynamic apps.
Value Types
Rhyme supports several fundamental value types:
Text (Strings)
Text values are enclosed in quotes:
$greeting = "Hello, World!"
$name = 'Alice'
$message = `Multi-line
text value`
Numbers
Both integers and decimals:
$age = 25
$price = 19.99
$temperature = -5.5
Booleans
True/false values:
$is-active = true
$enabled = false
$visible = on
$hidden = off
Dates and Times
Working with temporal values:
$today = $TODAY
$now = $NOW
$meeting = 2024-12-25
Value Operations
You can perform operations on values:
// String concatenation
$full-name = $first-name + " " + $last-name
// Math operations
$total = $price * $quantity
$average = ($score1 + $score2) / 2
// Comparisons
if $age > 18
.text "Adult"
Learn More
- Variable Types - How variables store values
- Data Operations - Working with data
- Math Actions - Mathematical operations
Working with Text
Text values (strings) are one of the most common data types in Rhyme. Here’s how to work with them effectively.
Creating Text Values
There are three ways to create text in Rhyme:
// Double quotes - most common
$message = "Hello, World!"
// Single quotes - useful when text contains double quotes
$quote = 'She said "Hello" to me'
// Backticks - for multi-line text
$poem = `Roses are red
Violets are blue
Rhyme makes apps
And so can you!`
Text Operations
Text in UI Elements
Text values are used throughout your UI:
Text
Text values (strings) are the foundation of user-facing content in Rhyme apps. They represent any sequence of characters - from simple labels to complex messages.
Creating Text Values
// Simple text
$greeting = "Hello, World!"
// Text with quotes
$quote = 'She said "Hello"'
// Multi-line text
$address = `123 Main Street
Apartment 4B
New York, NY 10001`
Common Uses
- UI labels and messages
- User input storage
- Dynamic content generation
- Data formatting
More content coming soon…
Number
Number values in Rhyme represent numeric data - both integers and decimals. They’re essential for calculations, counters, and any quantitative operations.
Creating Number Values
// Integers
$age = 25
$count = 100
// Decimals
$price = 19.99
$temperature = 98.6
// Negative numbers
$balance = -150.50
$below-zero = -5
Common Uses
- Mathematical calculations
- Loop counters
- Prices and currency
- Measurements and statistics
More content coming soon…
Switch
Switch values (booleans) represent on/off states in Rhyme. They’re perfect for toggles, flags, and any true/false logic in your app.
Creating Switch Values
// Using true/false
$is-logged-in = true
$debug-mode = false
// Using on/off
$notifications = on
$sound-effects = off
// Using yes/no
$agree-to-terms = yes
$show-tutorial = no
Using Switches in Conditionals
// Simple conditional with a switch
if $online :
.text "You are online"
:end
// Using the switch directly
if $notifications :
.sound "notification.mp3"
:end
// Checking false conditions
if not $debug-mode :
.hide ".debug-panel"
:end
Common Uses
- Feature toggles
- User preferences
- Conditional logic
- State management
More content coming soon…
Item
Item values represent individual elements from a collection or list. They’re used when working with single records or entries from larger data sets.
Working with Items
// Setting item properties
$record.name = "Bob"
$record.age = 42
// Selecting an item
$current-user = $users[1]
// Item from a list
$selected-product = $products[$index]
// Item properties
$user-name = $current-user.name
$user-email = $current-user.email
Common Uses
- Current selection tracking
- Form data handling
- Detail view display
- Single record operations
More content coming soon…
Group
Group values represent collections of related items. They’re essential for managing lists, arrays, and sets of data in your Rhyme apps.
Working with Groups
// Creating a group
$shopping-list = "Milk", "Bread", "Eggs"
// Group of items
$users = $user1, $user2, $user3
// Accessing group size
$total-items = $shopping-list.count
// Iterating through groups
foreach $item in $shopping-list :
.text $item
:end
Common Uses
- Data collections
- List management
- Bulk operations
- Loop iterations
More content coming soon…
Date
Date values represent calendar dates in Rhyme. They’re crucial for scheduling, tracking events, and any time-based functionality.
Working with Dates
// Current date
$today = $TODAY
// Specific date
$deadline = 2024-12-31
$birthday = 1990-05-15
// Date formatting
.text "Due date: $deadline"
Common Uses
- Event scheduling
- Due date tracking
- Age calculations
- Date comparisons
More content coming soon…
Time
Time values represent specific times of day in Rhyme. They’re essential for scheduling, timestamps, and time-based operations.
Working with Times
// Current time
$now = $NOW
// Specific times
$meeting-time = 14:30
$alarm = 07:00
// Times with AM/PM
$morning-meeting = 9:30a // value stored as 09:30
$lunch-time = 12:00p // value stored as 12:00
$afternoon-break = 3:15pm // value stored as 15:15
$closing-time = 7:00pm // value stored as 19:00
// Time formatting
.text "Meeting at: $meeting-time"
Common Uses
- Meeting schedules
- Alarm settings
- Time tracking
- Duration calculations
More content coming soon…
Duration
Durations let you work with time in your app. Think of them as a simple way to say “wait 5 seconds” or “show this for 2 minutes.”
How Durations Work
In Rhyme, you write durations as a number followed by a time unit:
// Basic duration examples
$quick-pause = 2s // 2 seconds
$loading-time = 500ms // 500 milliseconds (half a second)
$lunch-break = 1h // 1 hour
Time Units You Can Use
Here are all the time units available: