Ramda Logic Methods

Beginner
7 min read
Updated: Nov 2026
19 method guides
Method index

About This Index

This page is the Ramda Logic index for the tutorial track. Each row links to a full guide with syntax, examples, and FAQs.

Learn the Ramda overview on /ramdajs. Use this page when you need a logic API such as R.and(), R.ifElse(), or R.when().

Beginner path.

Start with R.and(), R.or(), and R.not()—then R.ifElse() and R.when() for branching in pipelines.

How to Call a Logic Method

Import R (or a named helper)—combine values, predicates, or branches with data last:

Ramda
const R = require("ramda");

R.and(true, false);                 // false
R.or(null, "ok");                   // "ok"
R.not(true);                        // false

const isEven = n => n % 2 === 0;
const gt10 = n => n > 10;

R.both(isEven, gt10)(12);           // true
R.allPass([isEven, gt10])(12);      // true

R.ifElse(isEven, R.inc, R.dec)(3);  // 2
R.when(isEven, R.inc)(4);           // 5
R.defaultTo(0, null);               // 0

Ramda Logic Methods Table

All Logic method guides in this Ramda tutorial series (19 tutorials).

Getting Started

6 methods

Value-level boolean helpers and the first two-predicate combiners in a Ramda tutorial.

MethodDescriptionTutorial
R.and()Return the first falsy value, or the second value when both are truthy. Works on values, not predicates.Try it
R.or()Return the first truthy value, or the second when the first is falsy. Works on values.Try it
R.not()Invert a boolean or truthy/falsy value directly.Try it
R.xor()Exclusive OR for two values. True when exactly one side is truthy.Try it
R.both()AND exactly two predicates. Think of it as the two-predicate cousin of R.allPass().Try it
R.either()OR exactly two predicates. True when either predicate passes.Try it

Predicate Combiners

3 methods

Build bigger checks from smaller predicate functions — allPass, anyPass, complement.

MethodDescriptionTutorial
R.allPass()Combine many predicates with AND. Returns one predicate that passes only when every test passes.Try it
R.anyPass()Combine many predicates with OR. One passing predicate is enough.Try it
R.complement()Invert a predicate result. Build a not-version of an existing test function.Try it

Branching & Flow

5 methods

Choose branches, conditionally transform values, or loop until a condition passes.

MethodDescriptionTutorial
R.cond()Run predicate/result pairs in order and use the first branch that matches.Try it
R.ifElse()Choose one of two functions based on a predicate result.Try it
R.when()Run a transform only when the predicate is true.Try it
R.unless()Run a transform only when the predicate is false.Try it
R.until()Repeat a function until the predicate becomes true.Try it

Fallbacks

1 method

Provide safe default values when incoming data is null, undefined, or NaN.

MethodDescriptionTutorial
R.defaultTo()Provide a fallback when the value is null, undefined, or NaN.Try it

Emptiness Checks

2 methods

Test whether arrays, strings, or objects are empty or not empty.

MethodDescriptionTutorial
R.isEmpty()Check whether a list, string, or object is empty.Try it
R.isNotEmpty()Check whether a list, string, or object has content.Try it

Property Predicate Helpers

2 methods

Run predicates against one property or a nested path inside an object.

MethodDescriptionTutorial
R.pathSatisfies()Run a predicate on a nested property found by a path.Try it
R.propSatisfies()Run a predicate on one named property of an object.Try it

Frequently Asked Questions

They are curried helpers for combining booleans and predicates, branching between functions, providing fallbacks, checking emptiness, and testing object properties—R.and, R.allPass, R.ifElse, R.when, R.defaultTo, and more.
R.and and R.or work on values. R.both and R.either combine two predicate functions and return a new predicate. Use and/or for values; both/either for tests.
Use R.both for exactly two predicates. Use R.allPass when you have a list of predicates or the set of checks may grow.
R.when runs a transform when the predicate is true. R.unless runs it when the predicate is false—mirrors for conditional pipelines.
Start with R.and(), R.or(), and R.not(), then R.ifElse() and R.when() from the table below.

Start with R.and()

Open the and guide—syntax, examples, and FAQs.

R.and() tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

16 people found this page helpful