---
title: "Discussion on \"Difference between break and return in ruby\" | Hashnode"
description: "Discussion on \"Difference between break and return in ruby\". What did I learn today 🤔\nI learned the difference between break and return keywords in ruby.\nDetails please\nreturn exits from the entire function.\nbreak exits from the innermost loop.\nThus, in a function like so:\ndef testing(target, method)\n  (0..10..."
url: "https://hashnode.com/posts/difference-between-break-and-return-in-ruby/5d9b27a69c373b3b0b66e3df"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [Difference between break and return in ruby](https://blog.kuda.dev/difference-between-break-and-return-in-ruby?utm_source=hashnode&utm_medium=feed)

What did I learn today 🤔 I learned the difference between break and return keywords in ruby. Details please return exits from the entire function. break exits from the innermost loop. Thus, in a function like so: def testing(target, method) (0..10...

Oct 7, 2019 · blog.kuda.dev  
Read the article

-   [#ruby](https://hashnode.com/tag/ruby)
-   [#til](https://hashnode.com/tag/til)

## Written by

[Kudakwashe Paradzayi](https://hashnode.com/@kudapara)

@kudapara · Harare, Zimbabwe

  
[View profile](https://hashnode.com/@kudapara)

Software Engineer

## Responses 2

Markdown supported · ⌘↵ to post

[j](https://hashnode.com/@chilimatic)

[Oct 10, 2019](https://hashnode.com/posts/difference-between-break-and-return-in-ruby/5d9b27a69c373b3b0b66e3df/comment/5d9eca22d7abec6c7987e369)

> return exits from the testing function whilst return exits from the (0..200).each loop.

don't you mean break exits the loop?

[Sandeep Panda](https://hashnode.com/@sandeep)

[Oct 7, 2019](https://hashnode.com/posts/difference-between-break-and-return-in-ruby/5d9b27a69c373b3b0b66e3df/comment/5d9b352b9c373b3b0b66e40e)

Cool :-) Why not tag it with TIL (Today I Learned) tag so that it appears here: [hashnode.com/feed/til](https://hashnode.com/feed/til?)

[Kudakwashe Paradzayi](https://hashnode.com/@kudapara)

[Oct 7, 2019](https://hashnode.com/posts/difference-between-break-and-return-in-ruby/5d9b27a69c373b3b0b66e3df/comment/5d9b352b9c373b3b0b66e40e#reply-5d9b44078b92ad3b2abccc82)

Thank you, I did not know about this tag. Fixing it now.
