Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Ruby custom inject
Language:
Ada
Assembly
Bash
C#
C++ (gcc)
C++ (clang)
C++ (vc++)
C (gcc)
C (clang)
C (vc)
Client Side
Clojure
Common Lisp
D
Elixir
Erlang
F#
Fortran
Go
Haskell
Java
Javascript
Kotlin
Lua
MySql
Node.js
Ocaml
Octave
Objective-C
Oracle
Pascal
Perl
Php
PostgreSQL
Prolog
Python
Python 3
R
Rust
Ruby
Scala
Scheme
Sql Server
Swift
Tcl
Visual Basic
Layout:
Vertical
Horizontal
# Put your solution there puts ([1, 2, 3].custom_inject([4]) { |a, e| a << e * 2 }).to_s # => [4, 2, 4, 6] puts ([2, 3, 4].custom_inject([]) { |a, e| a << e + 1 }).to_s # => [3, 4, 5]
[
+
]
Show input
Absolute running time: 0.14 sec, cpu time: 0.03 sec, memory peak: 6 Mb, absolute service time: 0,15 sec
edit mode
|
history
|
discussion
[4, 2, 4, 6]